Devlog ·

Bounce light from probes that know what they haven’t seen

Our 3D renderer gets its bounce light from sparse radiance probes, after a paper published this summer. Our first build of it lit a stone arcade several times too brightly. This is how we found out why, and how close it gets now, with the shader code and the numbers.

Sponza’s courtyard at midday, seen along its length from the ground: sun on the stone floor, coloured banners overhead, braziers burning beside red and green curtains, the far end of the courtyard bright beyond.
Sponza’s courtyard at midday, as the renderer draws it in real time. Whatever the sun doesn’t reach directly, the vaults, the shade and the curtains’ far sides, is lit by the braziers and by the bounce light in this post.

Sunlight that lands on a floor doesn’t stop there. Some of it bounces back up and lights the ceiling, the walls and the underside of every arch. That second-hand light is called global illumination, or GI, and in a lot of places it is most of the light there is. In the upper gallery of the Sponza atrium, below, the sun doesn’t reach the vault, the inner wall or most of the floor. Everything you see there is lit by the courtyard next to it.

Bounce light also takes the colour of what it bounced off. In a Cornell box the red and green walls tint the white surfaces next to them.

A Cornell box: a red wall on the left, a green one on the right, a tall white block and a soap bubble on a low one. The white walls are lit softly, faintly tinted by the coloured ones beside them.
A Cornell box. Little of it is lit directly: switched off, the bounce light takes almost the whole picture with it.
Sponza’s upper gallery in daylight: the vaulted ceiling, the inner wall and the floor are all softly lit, and the columns on the right stand against the bright courtyard. The same view with bounce light switched off: the ceiling, the wall and the floor are almost black, and only the sunlit columns and the courtyard beyond show.
Sponza’s upper gallery with bounce light and without. No sunlight reaches the vault, the inner wall or this stretch of floor. All the light on them has bounced at least once.

Working that out properly means following light from every surface in every direction, every frame. A path tracer does exactly that and takes seconds to converge. In real time you get a few rays a pixel, so the usual trick is to store the light that arrives at a sparse set of points, called probes, and let every pixel read the probes near it.

Where we started

Our probes follow Split Radiance Cascades (Freeman and Sannikov, 2026). Two of its ideas are what make it fit a ray tracer well.

  • Probes exist only where something visible needs one. They live in a hash table keyed by their grid cell, and every pixel on screen asks for the probes around it. A grid over the whole scene would be mostly empty space.
  • Rays come from the pixels, not from the probes. A probe sits near a surface and can end up inside it, so a ray cast from the probe itself is often blocked straight away. Instead each pixel casts rays from its own surface, and what each ray finds is filed into the probe nearest to where it started, in the direction it went. (The paper takes this from NVIDIA’s SHaRC radiance cache.)

The paper also stacks several of these probe grids into cascades, each coarser in space and finer in angle than the one below it. A ray’s length decides which cascade it counts for. Each of our probes stores 128 directions, cells of equal area on the sphere, 16 around and 8 from bottom to top. A pixel turns the light of its eight nearest probes into what its surface receives.

One more part of the paper matters below. A probe in a coarse cascade has many more directions than one in a fine cascade, and every direction a pixel will read needs rays. So the paper deals directions out per probe along a low-discrepancy sequence (its §5.1), so that every direction of every cascade gets visited evenly.

To check it, the renderer has a debug view that path traces the bounce light of the same frame, with six bounces, for as long as the camera holds still. Every number in this post is the probes against that reference, compared on the raw floating-point light, in 40-pixel blocks of the picture as drawn. The first time we measured on finished, tone-mapped pictures, the error came out about half of what it really was.

The upper gallery’s bounce light alone, from the probes: smooth light on the vault, the wall and the floor, brightest by the arches. The same bounce light from the path-traced reference: the same shapes and levels, with fine grain from the path tracer.
The bounce light alone, from the probes (left) and from the path-traced reference (right), tone-mapped the same way. The grain on the right is the path tracer’s own noise.

The first build: far too bright

Our first build, in October, drew the undersides of Sponza’s arches 2.4 times as bright as the reference, and we set it aside. (That and the numbers below come from different builds and different surfaces.) When we built it again, we took it apart against the reference one fault at a time. There were five. Three of them made most of the difference, and the next three sections are those. The other two were smaller: probes need their directions dealt out per probe, as the paper says, and a brand-new probe has to fade in, not arrive at full weight.

1. A probe is a cell and a facing

The underside of an arch and the sunlit wall above it can sit in the same grid cell. Keyed by cell alone, they shared one probe, and the probe’s rays were mostly the wall’s: the wall has more pixels, and they look out at the open sky. So the soffit was lit as though it faced the sky too.

Our probes are keyed by cell and by facing, one of the six axis directions (±x, ±y, ±z), plus the level of detail. Two surfaces that face different ways never share a probe.

uint64_t probe_key(ivec3 c, uint lod, uint facing) {
    uint64_t m = 0x3ffffUL;
    uint64_t x = uint64_t(c.x + 131072) & m, y = uint64_t(c.y + 131072) & m, z = uint64_t(c.z + 131072) & m;
    return (1UL << 63) | (uint64_t(facing) << 58) | (uint64_t(lod) << 54) | (z << 36) | (y << 18) | x;
}

A curved surface, like a column or a vault, faces several ways at once. It gets a probe in every facing its normal turns toward by at least 5% (as a share of the normal, squared). Each of its rays is filed into all of them, since the light arriving at a point is the same whichever probe keeps it. Each frame a pixel reads one of those facings, picked at random by how much it turns toward it, and the temporal filter averages them. A column shades round smoothly instead of switching probes at 45°.

2. A direction nobody looked at is unknown, not open

This was the biggest of them. In a cascade, each probe direction stores two numbers for its stretch of the ray: the light it found there (J) and how much light gets through from further away (β, the transmittance). A ray that hits something writes its light and β = 0. A ray that passes through writes β = 1. The cascades are then merged from the top down:

L = Jn + βn · Ln+1

The paper merges as normal and ignores directions with no rays, to avoid dividing by zero. It explains why empty directions shouldn’t matter: rays are only cast away from surfaces, an enclosed room never reads the cascades above, and the §5.1 dealing visits every direction evenly. Our build cast its rays the usual way for diffuse light, on a cosine lobe from each pixel, not dealt out per probe. With that, most fine directions of the coarse cascades got no ray on most frames.

And in our build, an empty direction read as zero light and full transmittance, which is exactly what open sky looks like to the merge. So every direction nobody had looked at was treated as a hole to the sky. Under a stone arcade that is a lot of sky: the arcade came out 2.3 stops too bright, about five times the light it should have had. So we made two changes. Directions are dealt out per probe, as the paper says. And an empty direction no longer means anything.

The fix is to keep three states apart: a ray stopped here, a ray passed through, and nothing is known. When a ray is filed, the count packs both into one word. The low half counts rays and the high half counts the ones that passed through, so a pass-through adds 65537:

void deposit(uint n, uint slot, vec3 w, bool stops, vec3 c) {
    uint at = n * DIR_SPAN + slot * cascade_dirs(n) + dir_index(w, n);
    if (stops) {
        atomicAdd(dep_cnt[at], 1u);
        add_float(dep_rad, 3u * at, c.r);
        add_float(dep_rad, 3u * at + 1u, c.g);
        add_float(dep_rad, 3u * at + 2u, c.b);
    } else {
        atomicAdd(dep_cnt[at], 65537u);
    }
}

The transmittance is then the high half over the low half. A direction that has never had a ray stores a negative transmittance, and anything that reads it gets no light and zero weight back, not the sky:

uvec2 h = hist[parity() * DIR_SPAN + slot * DIRS0 + d];
vec2 rg = unpackHalf2x16(h.x), bb = unpackHalf2x16(h.y);
return bb.y >= 0.0 ? vec4(vec3(rg, bb.x) + bb.y * sky_bins[d].rgb, 1.0) : vec4(0.0);

An unknown direction is left out of a probe’s mean, and the merge takes light from beyond only where some probe above actually saw that far. While we still ran several cascades, the merge read the eight probes of the cascade above, and there an unknown one had to count as weight with no light. Skipping it and renormalising let a probe on the far side of a wall, full of sky, stand in for it, and floors read 0.4 stops bright.

3. The back of a probe

A pixel doesn’t read 128 directions. Each probe’s directions are turned into spherical harmonics, a handful of smooth functions over the sphere that can be integrated against a surface’s cosine in one dot product (Ramamoorthi and Hanrahan, 2001). Four of them (L1) left walls, floors and ceilings a quarter of a stop out. Nine (L2) brought every region within about a tenth. The back of the probe came a few days later.

Nine harmonics still need a value for every direction, including the half behind the probe’s surface where no ray goes. What you put there decides how much the fit rings at the horizon. Filling the back with the mean of the known directions read 6% to 16% bright across our three test views. Filling it with the mirror image of the front, across the probe’s plane, read about 0.2 stops dark. Half of each brought the views to between 1% dark and 11% bright, though it made one view’s block error slightly worse (0.23 to 0.26 stops). It keeps the light continuous across the horizon:

vec4 r = bin_light(slot, d);
vec3 w = dir_centre(d, 0u);
vec4 mirrored = bin_light(slot, dir_index(w - 2.0 * dot(w, axis) * axis, 0u));
vec3 l = r.w > 0.5 ? r.rgb : (mirrored.w > 0.5 ? mix(mean, mirrored.rgb, 0.5) : mean);

Each probe is one subgroup of 32 lanes, and the sums over its directions are subgroup adds.

One cascade

With those fixed, the cascades above the first still read too bright at a distance: +0.32 stops at the far end of the arcade and +0.25 on the columns by the arches. Far away, a coarse cascade’s cell is metres across and pools surfaces that face the same way on both sides of a wall. Longer intervals didn’t help, and the extra cascades didn’t make the picture any less noisy either. So we run one cascade. With it, and all five faults fixed, the arcade came out 0.03 stops from the reference over the whole frame in a short run at the time. The hash table, the ray filing and the merge are all still general, but the shipped renderer has a single level of probes. They are spaced 18 pixels apart in the picture as drawn (about 24 screen pixels at 1080p, since the light is drawn at three quarters size), and a level of detail doubles their spacing in the world with distance, which keeps them between 9 and 18 drawn pixels apart.

The paper names this kind of fault itself: Split RC “can also exhibit light leaking” from interpolation, and misses details smaller than the base probe spacing.

Floors and the size of a direction

Floors were still a fifth too dark after all that. A probe had 32 directions then, only two rows to a hemisphere, so a floor’s top row spanned 30° to 90° above the horizon. The harmonics take each direction at its cell’s centre, so the sky straight overhead was filed as if it came from 49°. With 128 directions, four rows to a hemisphere, the courtyard floor went from 0.80 of the reference to 1.03. That cost 2.1 ms at first, which we took back by filtering each probe’s nine harmonics with its neighbours’ instead of all 128 directions, and by giving each probe one subgroup in the passes that work a probe at a time. It ended up at +0.55 ms.

What the probes can’t see

A probe averages a whole cell, up to 18 drawn pixels across, so it can’t see a crevice or the inside of a corner. So each pixel also casts one short ray a frame, four probe spacings long. If it hits something, it doesn’t replace the probe light with what it found. It adds the difference between what the ray found and what the probes say arrives along that same ray, counted less the further away the hit is. (The hit casts one more short ray of its own, and its cached light is dimmed as far as that one is blocked, so a crevice loses light at each bounce.)

vec3 e = max(weights.x * front.rgb + close.rgb - weights.y * along, vec3(0.0));

front is the probe light and along is the probes’ radiance along the short ray, read from their harmonics without the cosine. This is a control variate: the near hit adds the detail the probes blur and leaves the overall level to them. Our first version blended toward the near hit instead, which pulled each pixel’s light toward one ray and darkened the foot of every column. Switching to the difference brought the upper gallery’s block error from 0.140 stops to 0.123.

The same ray also darkens creases and corners on purpose, by up to 60% where it finds something close: within 30 cm, or four probe spacings where those are longer. That one is an exaggeration, not physics: real corner darkening is too faint to read on screen. It also accounts for some of the darkness on the floors in the numbers below.

Over time

One ray from every other pixel a frame is very little light. A probe direction keeps a running mean of every frame since the light last changed, up to about a thousand frames. The renderer counts how long the sun, sky and weather have held still, and any change to them wears that count down, so a still scene averages for a long time and a changed one catches up at once. Once the light and everything in the scene have held still for a whole history, a settled probe traces on only one frame in four. Rays from the pixels also look for the light: half of a probe’s rays go uniformly, and half pick a direction by the light the probe has already seen there. Each direction keeps the mean of its own rays, so guiding changes how noisy a direction is, never how bright.

The running mean is stored in half floats, which keep about three digits. Averaged over a thousand frames, each new frame moves the mean by a thousandth of the gap to the new value. Once that gap is small next to the value, the step is less than half a float’s last digit, so rounding to nearest throws it away, and the mean stops short. So each write rounds up or down at random, in proportion to how close each neighbour is, and the mean arrives on average:

float dithered_half(float v, float u) {
    uint bits = packHalf2x16(vec2(v, 0.0)) & 0xffffu;
    float near = unpackHalf2x16(bits).x;
    float other = unpackHalf2x16(abs(v) > abs(near) ? bits + 1u : bits - 1u).x;
    return near == v || other == near ? near : (u < (v - near) / (other - near) ? other : near);
}

One more thing we learned about filters, from before the probes, when the bounce light was per-pixel rays filtered by SVGF (Schied et al., 2017). SVGF writes its first filtered level back as the history, and finds that best balances stability and bias. In our arcade it made the light 0.05 to 0.14 stops darker, depending on how long the history was. The arcade’s light comes from a few rays that find the sunlit courtyard. The filter’s edge test keeps one of those bright samples out of its neighbours’ averages, while the sample itself still averages them, so its extra light is lost. Once the history is the filtered picture, it stays lost. So our history keeps the raw accumulation, and the filtered levels only go to the screen. A filter that is biased dark per frame mustn’t be allowed to feed itself.

Where it stands

We measured the current renderer again for this post: three views of Sponza at 1920 by 1080, each over 3000 frames, with the sun 60° up, by which time the reference held 472 paths a pixel. We measured at full size, as a player sees it. (Probes are spaced in pixels, so a smaller picture has coarser probes in the world, but at 960 by 540 the numbers came out much the same.)

The first run said the ground-floor arcade was badly wrong: its walls, floor and vault read 1.7 times the reference, and warm where the reference was cool. It was our measurement. Sponza’s courtyard has four burning braziers, and the light we compare carries their lamp light too, while the path tracer has no lamps at all. With the lamps off the arcade read 0.90 of the reference. The reference view now switches the lamps off by itself. These are the numbers with them off:

  • Upper gallery: the whole frame 0.05 stops darker than the reference. In 40-pixel blocks, the average block is 0.08 stops off.
  • The courtyard, seen down its length through an arch: 0.10 stops darker over the frame, blocks 0.12 stops off on average.
  • Ground-floor arcade: 0.12 stops darker over the frame, blocks 0.29 stops off on average.

So summed over a frame the probes read 3% to 8% darker than the path tracer. That sum is weighted by brightness, so the brightest surfaces count for most of it. Floors read 5% to 14% dark. Some of that is the corner darkening we add on purpose. Earlier ablations put the rest down to the probes’ resolution and the near-field ray’s estimate, but those ran with the braziers’ light in the comparison, so we haven’t split it fairly yet. The arcade is the darkest of the three, about a twentieth of the light on the courtyard seen through its arches, and its blocks are furthest off. That’s where we’d look next.

The ground-floor arcade’s bounce light from the probes: dim, cool light on the vault, the walls and the floor, a blue curtain on the left, the courtyard bright through the arch. The same from the path-traced reference: the same dim, cool light and blue curtain, with the path tracer’s grain, and the column plinths a little brighter.
The ground-floor arcade, probes (left) and reference (right), both with the lamps off. Nearly all the light here has come in off the courtyard.

Cost

In the view at the top of this post, at 1920 by 1080 on an RTX 5070, the GPU spends 22.9 ms on the whole frame. The bounce light is about 9.9 ms of that. Tracing the probes’ rays takes 5.6 ms. Reading the probes at every pixel takes 1.0, the short near-field ray 0.8, and the screen filter 1.0. Everything else the probes do (filing, blending, harmonics, filtering) adds up to 1.5 ms. All of it runs at three quarters of the picture’s size, and temporal upscaling brings it back to full size.

That was timed 600 frames in, before the probes settle and trace one frame in four. The tracing is the expensive part, and it is one ray from every other pixel. We tried two rays from each of those pixels twice. The first time it cut the arcade’s block error from 0.134 to 0.114 stops for 0.9 ms. The second time, a week later and after other changes, it cost 3.3 ms and we saw no difference in flicker or after a cut. So it stays at one.

Further reading

All devlog posts