12. Global Illumination

How light bounces — path tracing, radiosity, and the real-time approximations that fake it

In the real world, light doesn't stop after hitting one surface. It bounces — off walls, ceilings, floors, and objects — scattering color and energy throughout a scene. A single lamp in a room illuminates surfaces it can't even "see" directly, because light reaches them after one, two, or dozens of bounces.

Global illumination (GI) is the family of techniques that simulate this indirect lighting. Without it, any surface not directly lit by a light source is pure black (or filled with a flat ambient hack). With it, scenes look natural, grounded, and three-dimensional.

Direct vs. Indirect Lighting

Direct lighting is what we've computed so far: light travels from a source, hits a surface, and we shade it using Phong/Blinn-Phong. One bounce — source to surface to camera.

Indirect lighting is everything else: light that has bounced at least once off another surface before reaching the point we're shading. This includes:

  • Color bleeding — a red carpet casts a warm tint on a nearby white wall
  • Ambient occlusion — corners and crevices are darker because less indirect light can reach them
  • Caustics — focused light patterns from refractive or curved reflective surfaces (the bright ripples on the bottom of a swimming pool)
Total illumination = direct + indirect
                   = one-bounce + multi-bounce

The rendering equation (Kajiya, 1986) formalizes this:

L_o(p, w_o) = L_e(p, w_o) + integral[ f(p, w_i, w_o) * L_i(p, w_i) * cos(theta_i) dw_i ]
  • L_o — outgoing light at point p in direction w_o
  • L_e — emitted light (if p is a light source)
  • f — the BRDF (how the surface reflects light)
  • L_i — incoming light from direction w_i (which itself is the L_o of some other point — this is what makes it recursive)
  • cos(theta_i) — Lambert's cosine term

This integral has no closed-form solution for arbitrary scenes. Every GI technique is an approximation of this equation.

The Rendering Equation

The rendering equation is recursive — the incoming light at any point depends on the outgoing light at every other visible point. Solving it exactly for a complex scene is intractable. Every GI method is a strategy for approximating this integral efficiently.

Interactive

Direct vs. indirect lighting (Cornell box)

A Cornell box rendered three ways. Direct lighting leaves unlit areas black. Each indirect bounce adds color bleeding from the red and green walls and fills in the shadows.

Path Tracing

The most conceptually simple approach: for each pixel, cast a ray into the scene. When it hits a surface, randomly pick a new direction (weighted by the BRDF) and keep bouncing until the ray hits a light or is terminated. Average thousands of such paths per pixel and the result converges to the correct image.

function trace_path(ray, scene, depth):
    if depth > MAX_DEPTH: return black

    hit = intersect(ray, scene)
    if no hit: return sky_color

    // Direct: sample a light source
    direct = sample_light(hit)

    // Indirect: bounce in a random direction
    new_dir = sample_hemisphere(hit.normal, hit.material)
    new_ray = Ray(hit.point + epsilon * hit.normal, new_dir)
    indirect = trace_path(new_ray, scene, depth + 1)

    brdf = evaluate_brdf(hit.material, ray.dir, new_dir, hit.normal)
    pdf  = sample_pdf(new_dir, hit.normal, hit.material)

    return hit.emission + direct + (brdf * indirect * cos_theta) / pdf

Why It's Noisy

Each pixel traces a different set of random paths. With few samples, the random variation between pixels is visible as noise — a grainy, speckled image. More samples → less noise, but the convergence rate is slow: halving the noise requires 4x the samples (variance decreases as 1/N).

A 1080p image with 1024 samples per pixel means tracing over 2 billion paths. Offline renderers (Pixar's RenderMan, Arnold, Blender's Cycles) do exactly this and take minutes to hours per frame. Real-time path tracing is only feasible with heavy denoising.

Importance Sampling

Not all random directions are equally useful. A direction nearly parallel to the surface contributes almost nothing (the cosine term is near zero). Importance sampling biases the random distribution toward directions that contribute more:

  • Cosine-weighted sampling — more likely to pick directions near the normal
  • BRDF sampling — for glossy materials, concentrate rays near the reflection direction
  • Light sampling (next event estimation) — explicitly sample light sources instead of hoping a random ray hits one

Combining these strategies (multiple importance sampling, MIS) dramatically reduces noise for the same sample count.

Radiosity

A completely different approach, rooted in thermal engineering. Radiosity subdivides every surface in the scene into small patches and computes how much light energy transfers between every pair of patches.

The key quantity is the form factor — the fraction of energy leaving patch A that arrives at patch B, determined purely by geometry (relative position, orientation, and visibility):

F_AB = (1 / A_a) * integral_Aa integral_Ab [ cos(theta_a) * cos(theta_b) * V(a,b) / (pi * r²) ] dAb dAa

Where V(a,b) is the visibility term (1 if unoccluded, 0 otherwise) and r is the distance between the two points.

Once all form factors are computed, the system becomes a set of linear equations:

B_i = E_i + rho_i * sum( F_ij * B_j )
  • B_i — radiosity (total outgoing light) of patch i
  • E_i — emitted light
  • rho_i — diffuse reflectance
  • F_ij — form factor from j to i

This system can be solved iteratively (Gauss-Seidel, Jacobi) or progressively (shoot energy from the brightest patch first).

Strengths and Limitations

Radiosity naturally handles diffuse interreflection — color bleeding and soft indirect lighting. Because it's view-independent (the solution depends only on geometry and materials, not the camera), it can be precomputed and reused across frames.

The downside: it only works for perfectly diffuse (Lambertian) surfaces. Specular reflections and glossy materials need different techniques. And the O(n²) form factor computation is expensive for complex scenes.

Radiosity was groundbreaking in the 1980s and is still used conceptually, but pure radiosity has been largely superseded by more flexible methods.

Real-Time Approximations

Full path tracing and radiosity are too expensive for real-time rendering. Games use a combination of clever approximations:

Screen-Space Ambient Occlusion (SSAO)

The cheapest indirect lighting approximation. For each pixel, sample the depth buffer in a hemisphere around the surface point. If many samples are closer to the camera (occluded by nearby geometry), the pixel is darkened.

occlusion = 0
for each sample in hemisphere:
    sample_pos = fragment_pos + random_offset
    projected = project_to_screen(sample_pos)
    sample_depth = depth_buffer[projected.xy]

    if sample_depth < projected.z:
        occlusion += 1

ao = 1.0 - (occlusion / num_samples)

SSAO doesn't simulate light transport at all — it just darkens creases and contact areas. But it adds substantial depth and grounding to a scene for very low cost.

Interactive

Ambient occlusion

Left: direct lighting only. Center: the ambient occlusion buffer (darker = more occluded). Right: AO multiplied into the scene — notice how corners and contact areas are darkened.

Limitations: it only knows about surfaces visible on screen. An object just off-screen can't occlude anything. And it has no color information — it can't produce color bleeding.

Improved variants include HBAO (horizon-based), GTAO (ground truth ambient occlusion), and SSDO (screen-space directional occlusion, which adds a single bounce of color bleeding).

Light Probes and Irradiance Volumes

Place a grid of probes throughout the scene. At each probe, precompute (or bake) the incoming light from all directions, typically stored as spherical harmonics (SH) — a compact basis for representing directional functions.

At runtime, each fragment looks up the nearest probes and interpolates their SH coefficients to approximate the incoming indirect light:

// L2 spherical harmonics (9 coefficients per color channel)
irradiance = sum( sh_coeff[i] * sh_basis[i](normal) )
indirect_diffuse = material_albedo * irradiance

Spherical harmonics can't represent sharp features (they're smooth, low-frequency by nature), but indirect diffuse lighting is inherently low-frequency, so the match is good.

This technique powers indirect lighting in many game engines (Unity's Light Probes, Unreal's Volumetric Lightmaps).

Lightmaps

Precompute indirect lighting for every point on every static surface and store it in a texture — the lightmap. The renderer samples this texture at runtime just like a regular texture, adding the baked indirect light to the direct lighting computation.

Lightmaps can be extremely high quality (baked with a path tracer) and cost almost nothing at runtime — just a texture lookup. The downside: they only work for static geometry. Moving objects need a different solution (usually light probes).

Most game engines use lightmaps for static environments combined with light probes for dynamic objects.

Voxel Global Illumination (VXGI)

Voxelize the scene into a 3D grid of small cubes. During the lighting pass, store the direct illumination in each voxel. To compute indirect lighting at a fragment, cone trace through the voxel grid — cast several wide cones into the hemisphere above the surface and accumulate the light stored in voxels along each cone.

indirect = vec3(0.0)
for each cone direction:
    accumulated = trace_cone(voxel_grid, fragment_pos, cone_dir, cone_angle)
    indirect += accumulated * cos_weight

VXGI handles both diffuse and specular indirect lighting in real time, and it works with dynamic geometry and lights. The cost is the voxel storage (a 256³ grid is 16 million voxels) and the cone tracing passes.

Screen-Space Global Illumination (SSGI)

Trace short rays in screen space, reusing the color and depth buffers as a rough approximation of the scene. When a ray hits something in the depth buffer, use that pixel's color as the incoming indirect light.

SSGI inherits SSAO's limitations — it only knows about visible surfaces — but it provides color bleeding and short-range indirect bounces at low cost. It's increasingly common as a complement to probe-based systems.

Ray-Traced Global Illumination (RTGI)

With hardware-accelerated ray tracing (RTX, RDNA2+), trace a small number of indirect rays per pixel (1–2) and rely on temporal denoising to clean up the noise.

// Per pixel, per frame:
indirect_ray = random direction in hemisphere (importance-sampled)
hit = trace_ray(fragment_pos, indirect_ray)
if hit:
    indirect_color = hit.direct_lighting * hit.albedo

Accumulate results over multiple frames, using motion vectors to reproject previous frames' results onto the current frame. A denoiser (often AI-based) fills in the gaps.

This produces physically plausible GI that responds to dynamic objects and lights, but requires modern GPU hardware and a robust denoising pipeline.

Comparing the Approaches

Technique Quality Dynamic Cost Color Bleeding
SSAO Low Yes Very low No
Light probes (SH) Medium Partial Low Yes
Lightmaps High No (static) Very low Yes
VXGI Medium-High Yes Medium Yes
SSGI Medium Yes Low-Medium Yes
RTGI High Yes High Yes
Path tracing Reference Yes Very high Yes

Most shipped games combine several of these. A typical setup might use lightmaps for static indirect, light probes for dynamic objects, SSAO for contact shadows, and RTGI or SSGI as an optional quality upgrade.

Denoising

Real-time path tracing and RTGI produce noisy images at 1–4 samples per pixel. Temporal denoising is what makes them viable:

  1. Temporal accumulation — blend the current noisy frame with previous frames using motion vectors. Static regions accumulate samples over time, converging toward the correct result.
  2. Spatial filtering — for pixels that can't reuse history (disoccluded regions, fast motion), apply an edge-preserving spatial filter (bilateral, joint bilateral, or wavelet-based) using the depth and normal buffers to avoid blurring across edges.
  3. AI denoising — neural networks trained to reconstruct clean images from sparse samples (NVIDIA's DLSS, AMD's FSR, Intel's XeSS for upscaling; NRD for GI-specific denoising).

The combination of sparse sampling + temporal accumulation + AI denoising is the current state of the art for real-time GI.

What's Next

Global illumination completes the lighting pipeline — from direct shadows to the subtle interplay of light bouncing around a scene. Together with shadow mapping and bloom, these techniques form the foundation of modern real-time rendering. Each is an approximation, and the art of real-time graphics is choosing the right combination of approximations for the budget and visual quality your application demands.