Gamma Correction

As recently pointed out by John Hable of Naughty Dog here, gamma correction is an extremely important topic for graphics, but a topic that you never learn at school.

Basically, your monitor takes the framebuffer you send to it and applies a « gamma 2.2″ (e.g.: my_color^2.2), thus deforming, shifting your computed pixel values. When you try to output something linear, the screen shows something non-linear. You need to compensate for it !

« But what’s the problem ? When I paint my textures, I do it on a screen applying gamma, so they look exactly how I want them to look ».

Problem is that lighting calculations are linear by nature, and should be done in « linear space », not gamma space.

When your draw your texture, it looks good on screen (looks linear when you mean linear), so it is stored with gamma = 1/2.2 (sRGB) so that when the screen applies a gamma 2.2 it « cancels out » and looks linear.

When doing your lighting calculations, you want to bring your texture to linear space, applying pow(2.2), do your lighting, and apply a pow(1/2.2) before writing to the framebuffer in order to compensate for the monitor gamma.

Please refer to real articles on this topic, because my explanations are quick and not-clear. I just wanted to say that I applied that concept to our in-house product, and here are 2 screenshots demonstrating the huge effect it has on material rendering.

Gamma correction, color only

With bump and texture

As you can see, no hue shifting in the specular spots on the gamma corrected shots, and a really nice bump :)

Post a Comment

Your email is never published nor shared. Required fields are marked *