Per-Voxel-Face Irradiance Caching
Real-time global illumination baked into the world itself: every exposed voxel face keeps its own lighting, refined by rays every frame.
Clearing the cache to black, then flying down the spiral. Faces light up as soon as the camera's rays reach them, and stay lit after the camera moves on.
The third project in my voxel line, and the one the first two were building toward. It tests an idea I'd had in my head for years: bake lighting into world space and never stop baking. Every exposed voxel face stores its own light, rays refine it every frame, and drawing the frame is one ray per pixel plus a lookup.
0x01
Light that lives on the faces
Every exposed voxel face keeps its own irradiance: 8 bytes each, 163 million of them. Because the light lives in the world and not on the screen, it doesn't smear when the camera moves, and work done once keeps paying off every frame after.
0x02
Move the sun, the world keeps up
Every frame, about 100,000 rays land across the view. Each one estimates the light reaching the face it hit and blends it into that face's running average, capped at N samples. Small N (8 here) follows the sun within a few frames; large N is smoother but slower.
0x03
Infinite bounces for the price of one
Bounce rays don't keep path tracing. They read the cache wherever they land, so each round carries light one bounce further and the world settles into multi-bounce lighting at single-bounce cost. It's the same feedback trick probe-based GI like DDGI uses.
0x04
Soft shadows, no shadow maps
Each sample fires one shadow ray toward a slightly jittered sun. Averaged in the cache over many frames resulting in soft shadows.
0x05
How fast does it recover?
I swung the sun 90° in a single frame and measured error against a fully converged cache. N = 8 recovers fast but settles at 6.6% error and flickers about six times as much. N = 64 gets down to 2.8% but needs over 100 frames.
The slow tail is probably rarely sampled faces, and faces lit only by bounce light that can't settle until their neighbors do. That measurement led to my research proposal.
0x06
Where it started
The first working demo, on the original pit world, with a long and smooth history (N = 1024, 70,000 samples a frame). Everything above grew out of staring at this and asking why it was slow to react.
Technical notes
- Addressing. Every 8³ brick (the same brick the RT cores stop at in part 02) keeps a 512-bit mask of voxels with an exposed face. A face's slot is the brick's base + 6 × (set bits before this voxel) + face, so only surface voxels take up space.
- Storage. RGB irradiance plus a sample count, all f16, 8 bytes per face, about 1.2 GB total.
- Drawing. One hardware-traced ray per pixel (BVH to the brick, DDA inside it), then albedo × cached irradiance. No per-pixel path tracing.
- Whole-world bake. A button that skips the camera and bakes every face brick by brick.
- f16 drift. At high N, each update was smaller than half an f16 step and round-to-nearest threw it away, so converged faces drifted and banded. Stochastic rounding fixed it: the error now averages out to zero.
- Starting empty. Earlier versions pre-baked at load or seeded a grey guess. Now slots start empty, the first sample counts in full, and an unseen face is honestly black (the start of the hero video).
- Not done yet. The big merged solid boxes from part 02 have no per-voxel slots, so they get flat ambient light.
How this was built
Like the rest of the voxel line, this is a hobby case study. The idea, the direction, and the experiments are mine; most of the code was written with Claude Code while I learned the theory underneath it: irradiance, Monte Carlo estimators, cosine sampling, running means, and why f16 precision matters. It let me test the idea far sooner than I could have by hand, and I understand lighting much better for it.