A Path Tracer

One bounce at a time, from a single ray to ten million triangles.

San Miguel courtyard — afternoon sun through the tree canopy onto the stone floor and dining tables
FIVE CHAPTERS LATER  ·  SAN MIGUEL  ·  ~10M TRIANGLES  ·  CPU PATH TRACED

The path tracer starts as a question — what does this ray hit? — and ends as a courtyard rendered at ten million triangles, lit by an HDR sky and a hundred small lamps. Each chapter breaks an assumption the previous one was hiding behind.

Geometry comes first: rays, primitives, the bounding volume hierarchy that makes a hundred thousand intersections cheap. Then light, introduced stochastically — a pixel becomes the answer to an integral, solved by Monte Carlo with explicit connections to the sources. Surfaces stop being flat at the scale that matters; the BRDF grows three terms and a sampler that follows the lobe. Light passes through a surface, refracts, and emerges tinted by what it travelled through. The hand-placed sphere light is replaced by a sky and by every emissive triangle in the scene — and the scene itself becomes San Miguel.

The rendering equation does not change across the five chapters. What grows around it is the bookkeeping — acceleration, sampling, materials, transmission, scale — and each addition unlocks an image the previous chapter could not produce.

CHAPTERS

  1. 01

    First Hit

    — Ray Casting

    A CPU ray caster: sphere, box, cylinder, triangle, and the BVH that drops a single frame from 89 seconds to 130 milliseconds.

    Ray–primitive intersectionBVHMöller–TrumboreGLM
  2. 02

    Light Finds Its Way

    — Path Tracing

    Monte Carlo path tracing: cosine-weighted BRDF sampling, Russian roulette, and the shadow rays that reach a clean image in a tenth the passes.

    Monte Carlo integrationCosine-weighted samplingRussian RouletteNext-event estimation
  3. 03

    Mirrors

    — Microfacet BRDFs

    The Cook–Torrance microfacet BRDF — Phong NDF, Smith masking, Schlick Fresnel — and the multiple importance sampling that kills the fireflies it introduces.

    Cook-TorrancePhong NDFSmith GSchlick Fresnel
  4. 04

    Through Glass

    — Transmission

    A transmission lobe added to the BRDF: Snell refraction at every microfacet, total internal reflection, Beer's-law tint, and the power-heuristic MIS that quiets the sharper lobe.

    Snell refractionMicrofacet BTDFTotal Internal ReflectionBeer's Law
  5. 05

    The Room Itself

    — Image-Based Lighting & Scale

    Scaling to San Miguel and the Bistro: importance-sampled HDR environment lighting, an area light aggregated from every emissive triangle, a binary scene cache, and offline denoising.

    HDR Environment MapImportance-sampled CDFArea Light from emissive geometryBinary scene cache