Notice how the cloth in the image to the right looks more realistic and how much less plastic the specular reflections are.
The second reason for encoding images is based on how humans perceive light. Human vision is more sensitive to differences in shaded areas than in bright areas. Applying gamma encoding expands the dark areas and compresses the highlights which results in more bits being used for darkness than brightness. A normal photo would require 12 bits to be saved in linear space compared to the 8 bits used when stored in gamma space. Images are encoded with the sRGB format which uses a gamma of 2.2.
Mixing light spaces
Correct results are only achieved if both the texture input is decoded and then the final color is encoded. If only one of the operations is used the displayed image will look worse than if none of them are.
(c) Gamma decoding only, the texture is much darker and the lighting is incorrect.
When not to use gamma decoding
- Diffuse, specular and ambient occlusion textures all represent color modulation and need to be decoded on load
- Normal, displacement and alpha maps aren’t storing a color so the data they store is already linear
- When loading a gamma encoded image apply gamma decoding by raising the color to the power of 2.2, this converts the image to linear space
- After all calculations and post processing is done (the very last step) apply gamma encoding to the color by raising it to the inverse of the gamma of the monitor