The Math Behind Every Pixel

From rasterization to photorealistic ray tracing — master Computer Graphics concepts with interactive step-by-step visualizations. Built for CS students and 3D enthusiasts.

18+ Topics Planned
5 Core Modules
Visual Steps

Recommended Learning Path

Follow this order to build a solid CG foundation from basic pixel drawing to full rendering pipelines.

1
Primitives
2
Transforms
3
Camera
4
Lighting
5
Ray Tracing

Module Extras

Live
Interaction

GLUT Mouse Interaction

Track coordinates, capture mouse click states, and draw dynamic particle trails using GLUT's active and passive motion callbacks.

glutMouseFunc glutMotionFunc glutPassiveMotionFunc
Interaction

GLUT Keyboard Interaction

Capture ASCII character strokes and special function keys like arrows to rotate, translate, and interact with the teapot model dynamically.

glutKeyboardFunc glutSpecialFunc
Interaction

GLUT Menus & Colors

Build custom hierarchical right-click context menus. Dynamically register new color options and see the C++ code update on the fly.

glutCreateMenu glutAddMenuEntry glutAddSubMenu glutAttachMenu

Module 1 — Fundamentals & Rasterization

Live
Fundamentals

Bresenham's Line Algorithm

Draw pixel-perfect lines on a raster grid using only integer arithmetic. Understand why rasterization avoids floating point at the hardware level.

scanline decision param octants
d = 2Δy − Δx
Fundamentals

Midpoint Circle Algorithm

Rasterize circles efficiently using 8-way symmetry and the midpoint decision parameter — no trigonometry needed.

8-symmetry integer math pixel grid
f(x,y) = x² + y² − r²
Fundamentals

Scanline Polygon Fill

Fill convex and concave polygons using the scanline algorithm with an active edge table — the foundation of real-time rasterization.

active edge table parity test fill rule
Fundamentals

Cohen-Sutherland Clipping

Clip line segments to a rectangular viewport using outcode regions — essential for any rendering pipeline that handles off-screen geometry.

outcode TBRL bits viewport
Fundamentals

Sutherland-Hodgman Polygon Clipping

Clip polygons sequentially against individual viewport edges. Reconstruct the output vertex lists stage-by-stage.

polygon clip intersection vertices list
Fundamentals

GLUT & Double Buffering

Observe Front/Back buffer swapping, analyze C++ timer loops, and compare Single vs Double buffering flickering properties interactively.

event loop double buffering callbacks swap buffers
glutSwapBuffers()

Module 2 — 2D & 3D Transformations

Live
Math

2D Transformations

Translate, rotate, and scale 2D objects using matrix multiplication. Visualize how composite transformations work and why order matters.

translation matrix rotation matrix scaling composite
P' = T · R · S · P
Math

3D Transformations

Extend transformations into 3D space. Understand pitch, yaw, roll rotations and how 4×4 homogeneous matrices handle both rotation and translation.

4×4 matrix Euler angles pitch/yaw/roll
[x' y' z' 1] = [x y z 1] · M
Math

Bézier Curves

Understand parametric curves through control points. Watch de Casteljau's algorithm subdivide the curve step-by-step — the math behind SVG paths and outlines.

de Casteljau control points parametric t
B(t) = Σ C(n,i)·(1-t)^(n-i)·t^i·Pᵢ

Module 3 — Camera & Projections

Live
Camera

Camera & View Matrix

Position a virtual camera in 3D space with position, target, and up vectors. See how the view matrix transforms world coordinates to camera space.

lookAt world space camera space
Camera

Perspective Projection

Transform 3D coordinates to 2D screen space with the illusion of depth. Visualize the frustum, NDC coordinates, and how FOV affects the scene.

frustum FOV NDC near/far planes
x_screen = x/(z·tan(FOV/2))
Camera

Orthographic Projection

Project 3D to 2D without perspective distortion — used in architectural drawings, CAD software, and isometric games. Compare directly with perspective.

parallel rays no depth distortion CAD
Rendering

Z-Buffer Algorithm

Resolve depth ordering of overlapping surfaces per pixel. See how the depth buffer decides which fragment wins when multiple triangles cover the same pixel.

depth buffer fragment test overdraw

Module 4 — Lighting & Shading Models

Live
Rendering

Flat Shading

Compute a single color per polygon face using the face normal. The simplest shading model — fast but produces visible polygon boundaries.

face normal Lambertian N·L
I = kd · (N⃗ · L⃗)
Rendering

Gouraud Shading

Smooth shading by computing color at vertices and interpolating across the polygon. Eliminates harsh face boundaries seen in flat shading.

vertex normals bilinear interpolation per-vertex color
Rendering

Phong Shading Model

The standard illumination model combining ambient, diffuse, and specular components. Understand each term visually and why the specular exponent controls glossiness.

ambient diffuse specular shininess
I = ka·Ia + kd·(N·L) + ks·(R·V)^n
Texturing

Texture Mapping (UV)

Apply 2D images to 3D surfaces by mapping (u,v) texture coordinates to 3D vertex positions. Visualize how UV unwrapping works and what causes stretching.

UV coordinates texel sampling bilinear filter mipmaps

Module 5 — Advanced Rendering

Coming Soon
Advanced

Ray Tracing

Simulate the physical path of light by casting rays into a scene and computing intersections with geometry. The algorithm behind modern photorealistic rendering engines.

ray casting BVH reflection refraction shadow rays
Ray: P(t) = O + t·D⃗
Coming Soon
Advanced

Fragment Shaders (GLSL)

Write GPU programs that compute color per pixel. From procedural gradients to noise-based textures — understand how modern GPUs produce complex visual effects.

GLSL uniforms gl_FragCoord noise
Coming Soon
Advanced

Shadow Mapping

Render the scene from the light's perspective to create a depth map, then use it to determine which fragments are in shadow. The standard real-time shadow technique.

depth map light space PCF shadow acne
Planned

Track Our Progress

Computer Graphics visualizers are actively being designed. Check the roadmap to see what's coming and vote for what gets built next.

View Full Roadmap Request a Topic