home/ atoms/ gamma-correction-workflow

Gamma correction must be applied from the start of shader development, not added at the end

Display monitors apply a gamma curve (roughly power 2.2) to make pixel values perceptually linear. Physically-based lighting math works in linear light space. If you work in gamma space and then try to convert at the end, all tweaked lighting values are wrong. The correct workflow: work in linear light space throughout, apply pow(color, 1.0/2.2) only as the final output step. Working with it active from the start means every lighting tweak you make is calibrated in correct perceptual space.

Examples

fragColor = pow(col, vec3(0.4545)); — 1/2.2 ≈ 0.4545, applied as the last line before output.

Assessment

A colleague shows you a shader where gamma correction is applied mid-pipeline to just the specular component. What will go wrong and how would you fix it?

“gamma correction right from the beginning. It is not something you drop at the end to suddenly make everything physically correct or beautiful or perceptually meaningful”
corpus · inigo-quilez-live-coding-happy-jumping-video · chunk 5