Skip to content

Colour & Gamma

Split one lit sphere down the middle and light the two halves in different colour spaces.

What you should come away with: Why lighting maths done on sRGB numbers is wrong, and why the mistake looks like a style rather than a bug.

Assumes: Light & Normals. It will still make sense without it, but that one comes first.

Left of the divider: lit in sRGB · Right: lit in linear, then encoded

The numbers underneath

The number 0.5 is this much light
21.8%
Half the light is this number
0.730

At gamma 2.20. Those two rows are the whole problem in one line: the midpoint of the numbers and the midpoint of the light are not the same place, so every multiply done on the former is a multiply done on the wrong quantity.

Move the divider across the sphere. Both halves compute the identical Lambert term from the identical normal and the identical light — the only difference is whether the colour is decoded to light before the multiply and encoded back afterwards. The uncorrected half is darker through its midtones and its terminator is an abrupt edge rather than a roll-off, which is why gamma bugs get mistaken for artistic choices and shipped.

This is a correction as much as a lesson. Every other lab on this site had it wrong — the shared lit shader multiplied encoded values and wrote them straight out. That has been fixed, which is why the shading lab now looks slightly different from the screenshots in the earlier changelogs.