skip to content

Why does a renderer light the scene in linear HDR and tone map it, instead of clamping each pixel to the display range?

level: juniorimportance: should knowfreq 55%

answer

  1. real light spans huge ranges
  2. exposure first, then a curve
  3. a shoulder instead of a clip
  4. Reinhard versus filmic

basics

~20 s

Real light spans far more range than a display, so lighting is computed in linear floating point, then exposed and tone mapped by a curve that compresses highlights smoothly. Clamping instead turns bright skies flat white and shifts their hue.

solid answer

~50 s

Lighting must be added and multiplied in **linear** values to be correct, and real scenes span a huge range: a sunset sky can be thousands of times brighter than shadowed ground. So the renderer keeps **HDR** colour in floating-point targets and maps it to the display only at the end. The mapping has two steps: **exposure**, a scale set by hand or by auto-exposure from the scene's average luminance, and a **tone curve** that squeezes the unbounded range into what the display shows. **Reinhard**'s `L / (1 + L)` approaches 1 but never reaches it; **filmic** curves, and ACES-style transforms, add a toe that deepens shadows and a shoulder that rolls highlights off toward white. A hard clamp flattens everything above 1.0 to the same white and, because each channel clips at a different brightness, pushes an orange sunset toward yellow.

go deeper

for a junior

Recall that lighting is done in linear floating-point HDR and compressed for the display at the end, and be able to name exposure, Reinhard and filmic curves.

for a middle

Explain the chain: HDR targets, exposure and auto-exposure from average log luminance, the tone curve, grading, then display encoding, and why bloom comes before the curve.

for a senior

Diagnose washed-out, banded or hue-shifted output: double encoding, lighting on sRGB values, per-channel clipping, missing dither, or a UI caught by the tone curve.

for a principal

Own the colour pipeline as a standard: which curve and grading workflow artists author against, and how one linear scene image serves both standard and HDR displays.

## Why linear and why high dynamic range Light adds. Two lamps on a wall give the sum of their contributions, and a surface reflects a fraction of what arrives. That arithmetic is only correct on **linear** values, proportional to physical intensity. Real scenes also have a **high dynamic range (HDR)**: sunlit white stone can be thousands of times brighter than the inside of a shadowed doorway, while a standard display covers a far narrower range. If lighting were computed and stored in the display's 0-1 range, every bright light would clip during the computation and every sum after it would be wrong. So renderers compute lighting in linear floating point, write it to **floating-point render targets** (16-bit floats per channel are a common choice) and compress the range only at the very end. That last step is **tone mapping**. ## The chain from scene to screen 1. **Lighting** writes linear HDR colour. 2. **Temporal anti-aliasing or upscaling** usually runs on that HDR image; post-process edge anti-aliasing such as FXAA runs later, on the tone-mapped image. 3. **HDR effects** such as bloom and motion blur run while bright pixels still carry their real energy. 4. **Exposure** scales the image so the part of the range that matters lands in the useful middle of the curve. 5. A **tone curve** maps the unbounded range to 0-1, or to an HDR display's peak brightness. 6. **Colour grading** sets the look, often baked together with the curve into one lookup table. 7. **Display encoding** applies the display's transfer function, for example the sRGB curve for a standard display, with a little dither so 8-bit output does not band. 8. The **UI** is drawn on top in display space. ## Exposure and auto-exposure Exposure is a single multiplier, the renderer's equivalent of a camera's aperture and shutter. Fixed exposure suits authored shots; gameplay usually needs **auto-exposure**, which measures the frame and adapts: - Compute the **average log luminance** (a geometric mean, so one bright sun does not dominate) by repeated downsampling, or build a **luminance histogram** and ignore the darkest and brightest few percent. - Set exposure so that average lands on a target, classically middle grey around 0.18: `exposure = key / averageLuminance`. - Smooth it over time, so walking from a dark hall into the sun adapts over a second or so, like an eye, instead of jumping. ## Tone curves compared | Curve | Formula or shape | Behaviour | |---|---|---| | Clamp | `min(x, 1)` per channel | Everything above 1 is the same white; hue shifts as channels clip | | Reinhard | `L / (1 + L)` | Smooth and never reaches 1; flat, low-contrast look | | Extended Reinhard | `L * (1 + L / Lw^2) / (1 + L)` | Reaches exactly 1 at a chosen white point `Lw` | | Filmic | S-curve with a toe and a shoulder | Deeper blacks, highlights roll off and desaturate toward white | | ACES-style | Reference and output transforms, often approximated by a short fitted curve | A filmic look defined by a colour-management standard | Points interviewers probe: - Applying a curve **per channel** compresses the largest channel most, so very bright saturated colours drift toward white, which reads as film-like; applying it to **luminance** and rescaling keeps hue but can push one channel past 1. - Plain Reinhard never reaches 1, so nothing is ever pure white unless a white point is added. - A filmic **toe** darkens and adds contrast near black; the **shoulder** decides how gently highlights reach white. ## What clamping does to a sunset Suppose the sky near the sun is linear `(8, 3, 0.6)` after exposure and the sun disc is `(60, 30, 8)`. Clamping gives `(1, 1, 0.6)`, a pale yellow, and `(1, 1, 1)`, white: the warm gradient becomes a flat yellow-white band with a hard edge where clipping starts. Per-channel Reinhard maps the sky to about `(0.89, 0.75, 0.38)`, still orange, and the sun to about `(0.98, 0.97, 0.89)`, nearly white with a warm tint, and the transition between them stays smooth. The colour survives because no channel hits the ceiling. ## Bloom belongs before the curve **Bloom**, the glow around bright light, imitates light scattering in a lens or an eye. It is built as a chain: downsample the HDR image repeatedly to smaller sizes with a wide filter, then upsample back up, adding each level, and mix a small fraction of the result into the image. Doing this **before** the tone curve matters: a pixel at 60 contributes far more glow than one at 1 (sixty times more when no brightness threshold is applied), so only genuinely bright light blooms. After the curve both sit near 1 and would glow almost equally. ## Common traps - Doing lighting maths on sRGB-encoded colours, so falloffs and blends look wrong. - Tone mapping or display-encoding twice, which washes the image out. - Tone mapping the UI with the scene, which dims or tints it.

  • Why do renderers add a white point or a filmic shoulder instead of using plain Reinhard?
    Plain Reinhard approaches 1 only as luminance goes to infinity, so nothing in the frame reaches full white and highlights look grey and flat. Extended Reinhard chooses a white point that maps to exactly 1, and a filmic shoulder controls how quickly highlights reach white, which gives artists back contrast and real whites.
  • How does tone mapping change when the output is an HDR display?
    The curve targets the display's peak brightness instead of a 0-1 range, keeping more highlight detail, and the output uses an HDR transfer function. The scene is still the same linear HDR image; only the final curve and encoding change, which is why keeping everything linear until the end pays off.

Tone mapping is like a photographer shooting film: the scene's light is what it is, exposure decides which part of it lands in the film's sweet spot, and the film's response curve rolls a bright sky off gently instead of burning it to blank white the way a clipping sensor does.

  • Lighting can be computed directly on sRGB-encoded texture colours.
  • HDR rendering only matters when the player owns an HDR display.
  • Clamping each channel at 1.0 keeps the colour and only loses brightness.
  • Bloom should be applied after tone mapping so it stays in display range.
  • Reinhard maps bright values to exactly 1.0, so highlights become pure white.