The AgX curve
How to show, on a screen that has only 256 levels, a street where the sun on a window pane is thousands of times brighter than a wall in the shade.
The problem: the street has far more contrast than the screen
The renderer computes light as it is in the scene: one number per colour, with no limit. A wall in the shade receives little, a sky a lot, a reflection of the sun an enormous amount. In a sunlit street, the sun's reflection on a window pane can be about 65,000 times brighter than a deep shadow. Photographers count these gaps in stops: one stop is twice as much light. Doubling 16 times in a row gives 65,536: so the gap is about 16 stops. This is the unit on the ruler of the diagrams below.
Your screen, on the other hand, can only light each colour at 256 levels, from 0 (black) to 255 (the strongest white it has). So you need a rule that says, for each light in the scene, which level the screen lights. This is called a tone curve. AgX is one of them.
- range of light in a sunlit street, about
- 1 to 65,000
- levels per colour on the screen
- 256
- the scene's middle grey is displayed at
- 118 / 255
Two simple rules that fail, and AgX
Here is the same scale of light, from the darkest on the left to the strongest on the right, each stop doubling the light. It is shown in three ways:
The curve itself
Plotted on a chart, the “as is” rule rises and then stops dead at 255, as early as 2.5 stops above middle grey: everything brighter is lost. AgX follows the same line in the midtones, then bends: each extra stop rises less and less, and white is only reached beyond 6 stops. The sky and the reflection therefore stay distinct. The “scaled under the strongest” rule does the opposite: nothing is ever blocked, but everything is squashed down near the floor. The sunlit cobblestones fall to 3 out of 255, the sky to 22, and even the sun's reflection only rises to 99.
Colours fade as they do in a photo
An orange lantern, stronger and stronger. Displayed as is, its three colours block one after the other: red first, then green, so the orange turns bright yellow, then jumps to white all at once. With AgX, it stays orange while fading gently towards white, like a lamp that is too bright in a photo.
Why Blender's, and why a table
Every piece of software has its own variant. The Bevy engine, on which the client is built, has its own AgX, but it brightens the midtones by about a fifth compared with Blender's. Yet we compare the client's image with the one from Cycles, which Blender shows with its AgX. So we need exactly Blender's.
Rather than recode it and risk small differences, we asked Blender itself, once: “for each of these colours, what do you show on the screen?”. We took 64 levels of red, 64 of green and 64 of blue, from 11 stops below middle grey to 12 above: 64 × 64 × 64 = 262,144 colours. Blender's answers are stored in a 2 MB file.
Checked against images that Blender displays itself, this table gives the same result to within 53.9 dB, that is, with no visible difference. It is produced by tools/bistro/agx-lut.py and stored in assets/blender/agx-64.bin.