The algorithm at the end of the chapter, executed
Marching through a volume
Start with T = 1 and L = 0: all of the light behind the volume still reaches you, and the volume has contributed nothing yet. Then take one step at a time. Every step does the same two things — add what this slice contributes, attenuated by everything already in front of it, then reduce the transmittance for whatever comes next.
The ray through the volume
Drag the camera or the aim dot
camera
sample taken
current sample
inside the bounding box
skipped — empty space
The two accumulators
T — transmittance still remaining
1.000
Starts at 1 and can only fall. This is the fraction of the light from behind the volume that is still getting through.
L — radiance accumulated
0.000
Starts at 0 and can only rise. Each step adds its contribution multiplied by whatever T was at the time.
The colour this pixel has accumulated so far. At the end of the march this is what gets written to the framebuffer.
Marching
Every step, in full
| i | t | σt | Δτ | ΔL | T after | L after |
|---|
The loop body
—
Step
—
Distance t
—
Density here
—
This step’s share of the final L
Status
—
Watch which steps actually matter. Run the march to the end and look at the fourth readout as you step back through: the first few samples inside the cloud contribute almost everything, and by the time
T has fallen to a few percent, later samples are multiplied by so little that they change the result in the fourth decimal place. That is the entire justification for early‑ray termination — tick the box and the march simply stops once T drops below the threshold, discarding work that could not have altered the image. It is the volumetric equivalent of a depth test, and on a thick cloud it routinely halves the cost. Note also what happens if you turn the density down far enough: T never falls, no step dominates, and every single sample has to be taken. Thin media are the expensive ones.