Rendering in one paragraph
Rendering computes a 2D image from a 3D scene: geometry, materials, lights and a camera. There are two families of methods. Rasterization asks, for each triangle, “which pixels does it cover?” and is fast enough for games and viewers. Ray tracing asks, for each pixel, “what does a ray of light from here hit?” and handles reflections and soft shadows naturally, at a higher cost.
The rasterization pipeline
- Vertex stage — every vertex is multiplied by the model, view and projection matrices (3D math) to find where it lands on screen.
- Primitive assembly and clipping — vertices are grouped into triangles; parts outside the view are cut away.
- Rasterization — each triangle is converted to the set of pixel-sized fragments it covers.
- Fragment (pixel) stage — a small program, the fragment shader, computes each fragment’s colour from lights and materials.
- Depth test — the z-buffer stores the nearest depth seen at every pixel; a fragment farther away than what is already there is thrown out, so near surfaces hide far ones regardless of drawing order.
A modern GPU runs these stages for millions of triangles, 60 or more times per second. The 3D Studio on this site is a small rasterizer written in WebGL: its fragment shader computes flat shading from screen-space derivatives, colours back faces differently, and discards fragments beyond the section plane.
Shading models
| Model | Idea | Look |
|---|---|---|
| Flat | One normal per face | Faceted; shows the mesh honestly |
| Lambert (diffuse) | Brightness ∝ cos of angle to the light | Matte, chalky |
| Phong / Blinn–Phong | Adds a specular highlight | Plastic-like shine |
| PBR (metallic–roughness) | Energy-conserving microfacet model with base colour, metallic and roughness | Consistent, realistic materials under any light |
glTF uses the metallic–roughness PBR model, which is why a GLB looks the same in three.js, Blender and Android’s viewer.
Shadows, ambient light and other real-time tricks
Rasterization does not know about light bouncing, so real-time engines approximate it: shadow maps (render depth from the light’s view, then test against it), screen-space ambient occlusion (darken creases), environment maps for reflections, and baked lighting precomputed into textures.
Ray tracing and path tracing
A ray tracer fires a ray from the camera through each pixel, finds the first surface it hits, then fires more rays toward lights (shadows), in the mirror direction (reflections) or through glass (refraction). Path tracing follows many random bounce paths per pixel and averages them, producing true global illumination: colour bleeding, soft shadows, caustics. It is noisy with few samples, so modern renderers use denoisers. Since 2018, consumer GPUs include hardware to speed up ray–triangle intersection, and games now mix rasterization with ray-traced reflections and shadows.
Anti-aliasing, frame rate and resolution
Triangle edges drawn on a pixel grid look jagged. Multisample anti-aliasing (MSAA) samples coverage several times per pixel; temporal methods blend frames. Real-time targets are usually 30, 60 or 90+ frames per second; VR needs 72–120 to stay comfortable.
Newer representations
Not everything rendered today is triangles. Neural radiance fields (NeRF, 2020) and 3D Gaussian splatting (2023) reconstruct scenes from photos as fields or millions of soft blobs and render them directly. They look photographic but are not meshes, so they cannot be 3D printed without conversion. See 3D scanning vs photogrammetry.
Check your understanding
1. What does the z-buffer do?
It compares depths per pixel.
2. Which shading model does glTF use for materials?
That is why GLBs look consistent everywhere.
3. What is the main advantage of path tracing?
It simulates global illumination.