Feature Library

Bounced light indoors

2.32 GPU · 0.45 CPU ms
A still of the Bounced light indoors demo
Still
The live demo starts when it’s in view.Drag a box to move it: the light re-bakes as you go · drag elsewhere to orbit

Light that comes in through a window, lands on the floor and bounces round the room, worked out on the GPU in a few frames instead of the half a minute…

What it costs a frame

2.32 ms
0.45 ms
GPU
2.32 ms
CPU, median
0.45 ms
CPU, 95th pct
0.68 ms
Draw calls
22
Compute passes
1
Weight
Heavy

Measured 13 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 2.31–2.46, CPU 0.41–0.65 ms). What ran: Measured with the cube gliding round the room by itself and the grid re-baked as each bake ends (voxelize, then one pass from the last result over 5,460 probes, a quarter of them a frame, 32 rays each). The sun at 16:00 through a window and a door, shadows on. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool2.320.450.68
apple · Apple A19 Proin a browser tab · 16 November 20264.040.100.20
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20266.751.432.63

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

What it needs

Renders with
WebGPU or WebGLWebGPU where there is one, WebGL2 where there is not.
Your browser
Runs hereNo WebGPU needed
Depends on
three.js 0.187.0No other packages

What it’s for

  1. Interiors in a game or walk-through that must be darker than the yard outside, lit through their doors and windows
  2. Architectural and room-planner views where furniture moves and the light follows in a moment
  3. A building that changes in play: a wall knocked through, a door shut, a box pushed in front of a window
  4. Time of day moving the sun round a room, re-lit as it goes
  5. Lamps whose light bounces off the walls at night, without a light map bake
  6. Replacing a probe bake that renders cube maps from every probe (seconds to minutes) with one that runs while the scene plays

Pitfalls, in brief

  1. Without WebGPU, bake on the CPU (cpu: !bakesOnGpu(renderer), decided before construction: three builds the grid’s node round its atlas on the first compile, and the CPU’s atlas is a Data3DTexture, not the GPU’s storage texture).
  2. Create the BouncedLight and adopt() the hemisphere light before anything is compiled.
  3. Never hide or add a light to switch it off, the sun at night included: set its intensity to 0.
  4. Call warm() and wait for it before the first bake.
  5. A new solids object is the signal to re-voxelize: place() with the same key and the same object does nothing.
8 more in brief
  1. Only solids block light.
  2. Pick cells so the narrowest opening is at least two cells across: the source sized 0.28 m by 0.15 m cells so a 0.4 m slit window stays open. reference.ts can check it on the CPU (voxelize, then march through the opening).
  3. 32 rays a probe are noisy where a small bright patch (a sunlit floor) is seen by some probes and missed by their neighbours: walls look mottled.
  4. The grid holds light that bounces off surfaces, not a lamp’s own light on them: keep a real three.js light for each lamp, and hand the bake the lamp too (colour times intensity, reach, decay, cone).
  5. A ray that leaves the grid’s box sees the hemisphere’s sky or ground, so the box must enclose the whole building with a margin round it, and a building taller than reach from inside reads the sky at its far end.
  6. The view shaders sample the grid only inside its box, offset half a probe along the surface normal, so a floor samples the layer above it: keep one layer under the floor (gridBounds does), or the floor reads the probes inside its slab.
  7. Eye adaptation (adapt) lifts each probe darker than the open sky toward it in the publish pass only: changing it costs one publish of the result on screen, not a bake (while a bake’s own passes run, none: their publish takes it).
  8. One grid per page lights one building at a time (the source moves it to the building the player is in).
13 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac. Fully custom code.

three.js LightProbeGrid, LightProbeGridNode and LightProbeGridHelper (MIT): used from three’s own addons, not copied: the module fills the grid’s atlas in three’s own packing and L2 basis

Amanatides and Woo, “A Fast Voxel Traversal Algorithm for Ray Tracing” (1987): the cell-by-cell ray march

Ramamoorthi and Hanrahan, “An Efficient Representation for Irradiance Environment Maps” (2001): irradiance from nine spherical-harmonic coefficients, as three’s getShIrradianceAt evaluates it

Fibonacci sphere (golden-angle spiral): the rays round each probe

Majercik, Guertin, Nowrouzezahrai and McGuire, “Dynamic Diffuse Global Illumination with Ray-Traced Irradiance Fields” (JCGT 2019): the idea behind the refining passes: rays turned by a random rotation each update and blended into the last result

Shoemake, “Uniform Random Rotations” (Graphics Gems III, 1992): the random rotation

global illuminationbounced lightindirect lightlight probesLightProbeGridirradiance volumespherical harmonicsvoxelizationray marchingDDAcomputeatomicsstorage textureinteriorsarchitecturesunlampstime of dayeye adaptationTSLWebGPUthree.jswebgl fallbackcpu bake

Near it in the frame