rust
Indirect Light at a Pixel: Probes, a Radiance Cache and a Denoiser in Helio
The rewrite of Helio's global illumination since the radiance cascades post: a probe clipmap, a world-space radiance cache that lights every hit, one ray per block of pixels with ReSTIR reuse, a denoiser that keeps the mean, and what each setting costs and gets right against a path-traced reference.
If you saw the voxel hillside at the top and hoped this post was about our voxel engine, we don't blame you. We promise we will get there, we will get there, but that is a post for another day. Today is about the light falling on that hillside, and in particular the light that does not arrive straight from the sun: the glow that fills in shadows and carries colour from one surface to the next.
We last wrote about this in Radiance Cascades: Probe-Based Global Illumination. That post ended by saying the next step was waiting on hardware ray tracing, and since then we have rewritten Helio's global illumination. The ideas behind the rewrite are not new, and we did not invent any of them. Probe visibility moments are Majercik and colleagues' DDGI. Reusing samples across pixels and frames is Ouyang and colleagues' ReSTIR GI, built on Bitterli's resampled importance sampling. The world-space hash of irradiance is the family of NVIDIA's SHaRC and AMD's GI-1.0, and Lumen's world radiance cache belongs to it too. Thank you to the people who wrote them down.
Introduction: One Ray a Block
At the default setting Helio traces one ray for every block of 4 by 4 pixels. At 1920 by 1080 that is about 130,000 rays for the indirect light of the whole picture, a ray for every sixteen pixels, and the picture still has contact shadows in the corners of a room and colour bleeding from a lit wall to the floor beside it. Everything else is reuse: the rays of the last few frames, the rays of the neighbours, and a world-space cache of how much light arrives at each patch of surface, so that a ray that hits something does not need to start a path of its own to find out how bright that thing is.
This post goes from the probes to the pixels in the order the data flows. The probes come first, because they are what the rest leans on. Then the radiance cache, which is the piece that is new since June. After it the gather that spends one ray a block, the reservoirs that reuse its samples, the denoiser and the rule it follows, and a fault that made specks in tree crowns and the fix. The last section covers what each setting costs and how close it gets to a path-traced reference.
1. What Probes Can and Cannot Do
The clipmap is six cubic grids of 24 by 24 by 24 probes. Each grid has twice the spacing of the one inside it, starting at half a metre by default, so the spacings are 0.5, 1, 2, up to 16 m, and the half extents around the eye run from 6 m to 192 m. The grids are stored toroidally, which means a probe's storage coordinate is its world coordinate modulo 24, and a grid that scrolls resets only the slabs that came in. A probe is 72 words: irradiance divided by pi as first-order spherical harmonics in half floats, a state, and an 8 by 8 octahedral map of the mean and the mean square of the distance its rays travelled in each direction. The last part is DDGI's. A pixel that reads a probe weights it by the Chebyshev test of its own distance against those moments, so a probe on the far side of a wall does not leak its light through it.
Each frame updates 680 probes on each of the two finest levels and 340 on each of the four coarser ones, which is 2,720 probes, and each update traces 64 rays along a spherical Fibonacci set turned by a random rotation every frame. That is 174,080 probe rays a frame. Results blend into the probe with hysteresis: a weight of one over n for its first updates, then 3 percent for irradiance and 5 percent for the moments. A probe whose rays mostly meet the inside of a surface (a quarter or more) is inside the ground or a wall, and drops out with no weight.
The probe view in the editor draws each pixel's nearest probe: dark red inside geometry, dark purple not yet updated, cell edges darker.
Probes are cheap and smooth, and they have a resolution of about half a metre. A probe cannot say that a table's underside is dark where it touches the floor, and it cannot hold the two sides of a thin wall apart. Where a hit meets a surface a ray needs to know how bright that surface is, and a probe is a poor answer for that: the nearest probe is somewhere in the air.
2. Where a Surface Is Lit
The radiance cache answers that question once for a place on a surface, and every ray that needs it asks the cache. It is a hash of irradiance arriving at surface cells, direct and indirect kept apart. A reader multiplies by its own hit's albedo, so the cache holds no texture detail and a cell can be coarse.
A cell's key is the world cell of the hit counted in 64 bits per axis, the cell's level, the dominant side of the face turned toward the ray, and the ray's coordinate space. Cell sizes are powers of two from 2^-6 to 2^10 m, and the origin of the frame is a multiple of 1024 m, so a change of origin moves no entry. The level comes from the footprint of the reading ray at the hit and the eye's distance, whichever is coarser: a wide probe ray reads a coarse cell, a pixel ray near the eye a fine one. By default a cell is about 40 milliradians of its distance from the eye, which is 52 pixels wide at 1080p under a 45 degree field of view. A cell is a slab on its surface, its level's width across and an eighth of that deep, so ground with relief claims one cell for the relief it spans and never a pile of finer ones.
Hashing is buckets of 16 slots. A slot holds a checksum of its key and the frame it was last marked. The table has 2^18 slots by default at about 162 bytes a slot, which is 40.5 MiB, and the setting runs from 2^12 to 2^24. A cell that no reader has marked for 128 frames is evicted, and past half the slots the least recently read go first, exactly as many as the cells in use exceed that. Memory follows the surfaces rays reached lately and not the size of the world.
Each frame the cache spends a budget on its cells. The default is 32,768 rays, four rays to a lit cell, so at most 8,192 cells are lit in a frame, in this order: cells never lit, parts restarting, the refresh, then those still converging, the least of their history first. The refresh visits each cell once in frames, where 21 is the finest probes' own period. A settled static scene spends the refresh alone. A cell's rays are cosine distributed about its normal in a 2 by 2 set of jittered strata. Each ray's hit is lit with one light sample and one shadow ray, the sky's radiance on a miss, and the cache's own irradiance at the hit for the bounces after.
The fold folds those results into the cell in three parts. The direct and indirect parts are stationary, so each is the plain mean of its updates since it last restarted, taken over as many updates as bring the relative standard error to 3 percent, which is 16 to 64. The bounced part follows the cells it reads, and averages 16 updates, so a second and third bounce settle in a few dozen. A change test of a fast mean over 4 updates against the history restarts a part when the light moved: a lamp switched on, a door opened.
2.1 Who Gets to Make a Cell
The first version let every reader claim cells, the probes, the cache's own rays and the pixels. It did not scale. The cells in use turned out to be the closure of the readers' cells under the cache's own rays, since every cell's rays claimed the cells they met, plus every probe's surroundings at the eye's angle. On the forest scene of voxel_craft the table sat at its load at any size, with 37,000 new cells in every frame. Now only the screen's reader claims cells: the pixels' gather, or the probes when there is no gather. The cache's rays and, at the gather's settings, the probes only read. A ray that finds no cell lights its hit on the spot with a light sample of its own and the probes' irradiance, which is DDGI's old recursion. This is the rule SHaRC and GI-1.0 follow, that only camera paths create entries.
The debug view of the cache draws the cell a pixel-wide ray would read at each pixel's surface: its irradiance over pi, dark purple where no cell holds a value yet, the edges of cells darker.
2.2 Where a Cell's Light Holds
A coarse cell has a problem at a wall. The cell's light is the average over its patch, and a patch that straddles a thin wall or a slab's edge has a lit side and a dark one. So each cell remembers how far from its point, along its surface, its rays found nothing in the way, in eight directions. A way no ray has explored yet holds a thirty-second of the cell. A way that an update's ray finds clear grows by . A reader on a surface that turns away from the cell's, or farther along it than that, reads the finer cell whose light holds there, at most three levels finer, and a mark claims those finer cells. A cell wider than a thin wall lights its own side only. A read that finds nothing says why: the cell is new, its way is unexplored, an occluder holds its light, or the key is absent because the full table turned it away. The statistics count each reader's hits by that state, which is how a leak is traced.
3. One Ray a Block
The setting is called quality, and it has four values. Probes only is the cheap one, the resolve as it was. The others take the indirect diffuse from rays that start at the pixels: one a block of 16 pixels, of 4, or one for every pixel. The default is one in 16.
For a block of pixels, the traced pixel inside the block rotates from frame to frame, and sends one ray cosine distributed about the G-buffer's normal. The directions come from Roberts' sequence over the frames, shifted by a hash of the texel, in 32-bit fixed point so the sequence is exact at any frame number. The ray's width at its origin is the block's footprint, which is the patch one ray's estimate stands for, and it spreads by per unit of distance, the share of the hemisphere a 32-frame history holds. Its hit is lit from the radiance cache, and the cell it reads is claimed at the footprint of the ray there.
The ray's hit has direct light of its own, from a light query into the frame's light samplers, with a shadow ray to the light. One ray per block sees a sample of the hemisphere. It does not see occlusion nearer than the block, which is why there is a second part, the near field: for every pixel, along 4 slices on both sides (8 azimuths), a horizon search over the depth buffer out to the block's width counts the occluders within that footprint and no farther. The result is a share of the cosine-weighted hemisphere left open, . The pixel's factor is its over the mean of its block, so the near field moves light between the pixels of a block and never changes the block's mean.
The first near field divided the signal by the traced pixel's and multiplied by each pixel's own. The block mean version replaced it because the division counted a near occluder's light twice: a ray that meets a close wall brings back that wall's light, and dividing by its counted that light again. At a block of one pixel the factor is 1 by construction.
4. Reservoirs
One ray a block is noisy. The reuse is ReSTIR GI: each traced pixel keeps a reservoir holding the sample it chose, and a new sample competes against the one from the last frame and against four neighbours' samples. The reuse uses generalised resampled importance sampling with the balance heuristic over each receiver's target function, which is the light times the geometry term. A kept sample counts for up to samples, so that a sample stays about nine frames and the denoiser's 32-frame history rests on at least independent samples while the resampling still chooses among eight samples' worth. A neighbour is a disc of 3 texels turned every frame, which is as far as the denoiser averages anyway.
A reservoir is 36 bytes. The receiver is three full floats from the eye, and the sample is a direction and distance in 16 bit fields, with a normal in 8 bits per axis. The receiver started as a 16 by 16 bit direction and put bright discs on voxel ground from some tens of metres, since a sample's weight is taken at its receiver's exact point and a hit a few ray offsets from it changes the geometry term by orders of magnitude.
When light changes, kept samples have to find out. One texel in four retraces its previous sample each frame. The cache's light at the sample now is compared against the luminance kept with it, and if the change is beyond the cache's own noise, , then the confidence handed to the denoiser drops by the excess and so does the reservoir's . A light switched on or off reaches every reservoir within four frames, 67 ms at 60 Hz, for a quarter more rays. A sample that was reused from a neighbour gets a visibility ray, since the neighbour may stand across a wall. Without those rays the far side of a half-height wall in a test scene read 1.49 to 1.53 of the reference and with them 0.92 to 1.05.
5. A Denoiser That Keeps the Mean
The denoiser is a contract before it is a pass. A producer describes a signal, its kind, its resolution against the internal one, its hit distance, and optionally a confidence in that its history still describes the light. It gets back the filtered signal. The pass behind it, helio-pass-denoise, reprojects through the frame's history, accumulates for a length that follows geometric validity times the producer's confidence, reconstructs widely where the history is short, and then filters spatially with stops that come from geometry only: depth, normal, an occluder the depth buffer shows between two receivers, and the hit distance.
The first version weighed what it averaged by the light the samples carried. A spatial stage with a luminance stop is SVGF's standard design, and its stop weights each neighbour by with the standard errors estimated from each pixel's moments. For a positive heavy-tailed signal, a few rays in a block finding a bright lamp among many that find nothing, the estimates that hold a bright sample are the ones with a high estimated variance, so they count less. The mean is biased low, and because the output is the next frame's history the bias recurs. Three more terms showed once the first were found: chroma averaged with the samples' weights instead of their luminance, a temporal stage that held each sample over the radius of its own hit distance, and a plane stop that dotted frame-space normals with view-space offsets.
The rule that came out of it is short. A weight that decides how much a sample counts must not depend on the sample's light. For a normalised filter whose weights are independent of the values, a stationary signal of mean has expectation
at every pixel, whatever the noise's distribution. A convex mix of two such estimates with weights independent of both keeps it, and so does the recurrence. Colour is a ratio, and its luminance-weighted mean is the ratio of the means of and , so it is kept the same way. No weight depends on the light being filtered, so a signal's mean survives whatever its noise.
5.1 A Young Pixel Leans on a Prior
The mean being right does not make every pixel right every frame. In the voxel scene's tree crowns, sixteen frames after a one radian look around, the gather left speckles: 120.6 speck pixels a frame against a test limit of 20, and 10.1 with the probes alone. The denoiser's per-pixel state showed that 87.8 percent of the speck pixels had a history of one frame or less. Three percent of the rays in those crowns ended within a centimetre of the receiver and carried 35 percent of the light, 11 times the mean sample: a voxel face in a concave corner with the neighbouring cell's face sunlit. That tail is real direct light, unbiased, at a scale below the block, and one sample a block cannot resolve it. The denoiser's job is to average it, and in a crown it had nothing to average with.
There were two causes. The temporal stage multiplied a history's length by the share of its bilinear footprint whose taps held the pixel's surface. Under the anti-aliasing jitter a sub-pixel leaf moves under a pixel every frame, so most canopy pixels keep two or three of their four taps, and a length scaled by 0.5 to 0.75 every frame settles at , one or two frames, however long the camera stays. The taps that held the surface hold its samples, renormalised, so the length is now the held taps' length, and that alone took the count from 120.6 to 42.9.
The second cause is that a genuinely young pixel, a disocclusion or a view just turned, rests on a sample or two and one of them is the tail. The denoiser now reports the samples' worth behind each estimate, and the reader that has a low-variance estimate of the same light, its prior, weights the two by the samples each is worth. The prior's weight is , because 16 is the worth the spatial stage widens to, so the prior fills exactly the deficit the geometry left. For GI the prior is the probes' irradiance. With both changes the final build counts 16.6 and 17.1 speck pixels against the limit of 20.
It is applied after the denoiser and never into its history. Fed back every frame, a prior worth samples holds a running mean of light at whatever its length, a bias that never settles. A settled pixel, , is the denoiser's own exactly. A young one is pulled toward the probes by of their difference, and since the probes read 0.89 to 0.99 of the reference in the cathedral where the gather reads 0.97 to 1.03, a pixel with no samples yet is up to about 10 percent darker than its settled self for the few frames its history takes to fill. The name for the idea is shrinkage toward a prior, and it is James and Stein's.
6. Settings, and What They Cost
The settings are one group, Global Illumination. The quality has four values, sample reuse is a toggle, and four numbers reach the cache and the probes: probe spacing, radiance cache slots as a power of two, cache rays a frame, and cell angle in milliradians. Zero means the default for each.
The costs below are for voxel_craft at 1920 by 1080 on an RTX 3060, two runs a setting, GPU medians over 240 frame windows. The whole frame at each setting:
| probes | 1 in 16 | 1 in 4 | every pixel | |
|---|---|---|---|---|
| whole frame, ms | 14.79 | 18.59 | 23.65 | 45.55 |
| over the probes, ms | 0 | 3.8 | 8.9 | 30.8 |
The default costs 3.7 to 3.8 ms over the probes, a quarter 8.8 and every pixel 30.7, of which the terrain's walk of the two ray sets is 21.5. Most of what scales is the tracer's walk of the rays: the walk of the visibility rays alone goes from 0.68 ms at one in 16 to 9.2 at every pixel. The denoiser is flat at 0.87 to 0.99 ms across the three, since it scales with pixels. The gather's own passes are small. Memory scales with what it should: the probes are 6 by 24 cubed by 288 bytes, 24 MB, the cache 40.5 MiB at the default, the ray streams 16.5 MB, 4.2 MB and 3.1 MB.
These timings predate the latest renderer merge and have not been measured again since.
6.1 Against a Reference
The accuracy numbers use Helio's path-traced reference, which converges in the same scene. The cathedral at frame 3000, as a mean ratio of the gather's linear luminance to the reference's over the pixels the reference lights, and the mean relative error per pixel after a 5 pixel blur of both. The numbers are the final build over 16 frames, two runs:
| setting | run a | run b |
|---|---|---|
| probes | 0.830 / 0.183 | 0.838 / 0.178 |
| 1 in 16 | 0.991 / 0.088 | 1.029 / 0.107 |
| 1 in 4 | 1.173 / 0.226 | 1.064 / 0.131 |
| every pixel | 0.978 / 0.089 | 0.922 / 0.100 |
The probes read about 83 percent of the reference's light and their error is nearly twice the gather's. The gather at one in 16 lands within a few percent of the mean with a per pixel error near 0.1. The quarter setting reads high in run a, 1.173, and this is a state the run settles into and keeps: the left wall at 1.2 to 1.4 of the reference in every quarter run, the floor at 1.0 in one run and 1.35 in another, and not at a sixteenth or every pixel. The cause is open. Run to run, rows with the same estimator differ by up to 4 percent at a quarter and 9 percent at every pixel, because the cathedral's cache, lit by many lamps, settles differently depending on when the pipelines compiled.
For scale, there are published figures for Lumen's screen-probe gather, which Wright's 2022 SIGGRAPH talk puts at about 2 ms at 1080p on a PS5 or RTX 2080 class GPU at the high scalability setting, and for AMD's GI-1.0 at 2.5 to 3 ms. Those are for other GPUs and other scenes, so they do not rank against 3.8 ms on voxel_craft.