Introduction#
A screen can only show brightness from 0 (black) to 1 (its brightest white). Real light doesn’t stop at 1: the sun is millions of times brighter than a dim room, and even a light bulb is far brighter than a white sheet of paper. If a game simply cut everything off at 1, every bright light, sky and reflection would flatten into the same dull white. This post covers how games handle that:
- High dynamic range (HDR) rendering: keeping brightness above 1 while drawing
- Exposure and tone mapping: squeezing it onto the screen at the end
- Bloom: the glow around bright lights, made with the blur from the previous post
Keeping the Full Range#
The first step is to stop throwing brightness away. Instead of drawing into a normal 8-bit render target, which can only store 0 to 1 in 256 steps, the scene is drawn into a floating-point render target, usually 16 bits per channel (“half floats”), which can store values far above 1 with plenty of precision. A glowing lamp can be 20, the sky 5 and a shadowed wall 0.05, all at once. All the lighting is done in linear light (sRGB and gamma), so these numbers really are proportional to the amount of light.
Only at the very end of the frame is this HDR image converted to something the screen can show.
Exposure and Tone Mapping#
A camera has to solve the same problem, and the first tool is the same: exposure. Multiplying the whole image by a number makes it brighter or darker, like opening up a camera’s aperture (the hole that lets the light in). Exposure is often measured in stops (EV), where each stop doubles or halves the light. Games often adjust it automatically, which is why stepping out of a dark cave makes the world briefly blinding.
But exposure alone can’t fit a scene with both deep shadows and bright lights into 0 to 1. Tone mapping is a curve that squeezes any brightness, however large, into that range, compressing bright values more and more so they never quite reach 1, while leaving dark and middle values nearly untouched. The demo below compares a few, after drawing a dark room lit by three glowing balls in HDR. Drag to look around.
An HDR scene with exposure, tone mapping and bloom
Things to try:
- Turn bloom off and set tone mapping to None. The glowing balls are flat discs of colour, and the orange one turns a pale yellow, because its red and green channels both hit the limit of 1 and lose their difference. This is what happens without tone mapping.
- Switch to Reinhard, which divides each value by one plus itself: x ÷ (1 + x). Brightness of 1 becomes 0.5, 10 becomes 0.91, 100 becomes 0.99, so nothing is ever cut off, and the balls get shape again. But mid-tones are dimmed too, and the image looks washed out.
- Switch to Filmic, a curve designed to imitate the response of camera film. It keeps rich contrast in the shadows and mid-tones and rolls the highlights off gently. It’s a fitted approximation of the curve used by ACES, a standard from the film industry, and similar curves are used by many games.
- Raise and lower the exposure: tone mapping keeps the image looking natural across a much wider range than simply cutting everything off at 1 (called clamping).
The second demo plots the three curves: drag across it (or use the slider) to compare them at any brightness. Notice that with no tone mapping, every brightness above 1 looks exactly the same.
The formulas behind the three curves
For a scene brightness x (applied to red, green and blue separately):
- None (clamp): min(x, 1): anything above 1 becomes 1.
- Reinhard: x ÷ (1 + x).
- Filmic (ACES fit): (x × (2.51x + 0.03)) ÷ (x × (2.43x + 0.59) + 0.14), then clamped to 1. It’s a ratio of two simple curves, with numbers chosen by Krzysztof Narkowicz to closely match the much more complicated ACES curve. Near 0 it rises slowly (deeper shadows), in the middle it’s steep (more contrast), and for very large x it creeps towards 2.51 ÷ 2.43 ≈ 1.03, which the clamp trims to 1.
Exposure simply multiplies x before any of these, like letting more light into a camera.
Tone mapping curves: scene brightness in, screen brightness out
Bloom#
When you look at a bright light, through your eyes or a camera lens, it seems to glow and spill over its surroundings. That’s caused by light scattering inside the eye or lens. A screen can’t actually be bright enough to cause it, so games fake it with bloom:
- Bright pass: copy only the parts of the HDR image brighter than a threshold into a smaller render target (a quarter of the resolution here).
- Blur it heavily, using the separable Gaussian blur from the previous post, several times over.
- Add the blurred result back on top of the HDR image, before tone mapping.
Choose Show: Bloom only to see what gets added. Lower the threshold and more of the scene glows; raise the strength for a dreamier look. It’s an effect that’s easy to overdo, which many games of the late 2000s famously did.
What the bright pass does, exactly
For each pixel, the demo takes its brightness as its largest channel, b = max(red, green, blue), and keeps only the part above the threshold: the colour is multiplied by (b − threshold) ÷ b, or by 0 if b is below the threshold. So with a threshold of 1, a pixel of brightness 3 keeps two thirds of its colour, one of brightness 1.2 keeps a sixth, and anything up to 1 adds no glow at all. Scaling all three channels by the same amount keeps the glow the same colour as the light.
A 16-bit float render target takes twice the memory, and twice the memory traffic, of an 8-bit one, which matters at 4K. Engines sometimes use cleverly packed formats that squeeze red, green and blue floats into 32 bits per pixel (dropping alpha) to keep the range for less. Bloom is usually built from a chain of downscaled images, each half the size of the last, blurred and added back up the chain; blurring at low resolution is cheap, and combining several sizes gives a glow with a bright core and a wide, soft halo. Finally, “HDR rendering” is a different thing from an “HDR display”: HDR rendering is about calculating with a wide range internally; an HDR display can show brighter whites than 1, so the tone mapping step for it maps to a wider output range instead.
Questions You Might Have#
Which tone mapping curve do games use?
It’s an artistic choice. Filmic curves like the ACES fit here are very common; newer ones such as AgX and engine-specific curves aim to handle very bright, saturated colours more gracefully. Many games let artists adjust the curve per scene.
Summary#
- HDR rendering stores linear light above 1 in floating-point render targets.
- Exposure scales the whole image; tone mapping squeezes any brightness into 0 to 1 without cutting it off.
- Filmic curves keep contrast and roll off highlights smoothly; Reinhard is simpler but flatter.
- Bloom = bright pass + heavy blur + add back, to imitate glare around bright lights.
Next, the last part of the series: anti-aliasing, smoothing jagged edges, with some of the techniques running as post-processing passes like the ones in this series.
Further Reading#
- LearnOpenGL, HDR and Bloom: both effects step by step in OpenGL.
- Krzysztof Narkowicz, ACES Filmic Tone Mapping Curve: the fitted curve used in this demo.
- Erik Reinhard and others, Photographic Tone Reproduction for Digital Images (SIGGRAPH 2002): the paper behind the Reinhard curve.
- LearnOpenGL, Physically Based Bloom: the downscale-and-upscale bloom chain used by modern engines.