Gamma Correction and Gamma Correction

Gamma Correction and Gamma Correction

Hi everybody. It’s been a while since my last post, mainly because I’ve left Naughty Dog and started my own company. Suffice it to say, I’ve been very busy and feverishly coding. Don’t have anything to say about it right now other than it’s going to be cool and it’s not going to be a game. Btw, U3 is going to be crazy. And yes, I need to fix that image on the right.

Back on topic, one issue that always confused people is the terminology around gamma correction. Sometimes, when I’m talking about the issue, someone will say “It doesn’t matter because people have poorly calibrated TVs?” The answer is “Wrong Gamma Correction”. This kind of confusion happens all the time because we have two completely separate problems in CG/Video Games and they are both called “Gamma Correction”.

Problem 1: Gamma Correction (Linear Space Lighting) This problem is making sure that all your lighting calculations are done in the correct space internally. You fix this problem by “Gamma Correcting” your textures in your shader. I.e. convert from sRGB to linear. And then at the end of your lighting calculations, you have to convert from linear back to sRGB, which is what we usually assume your output color profile is.

This problem is HUGE. If your goal is photoreal-ish visuals and you do not solve this problem then you are screwed. You MUST deal with this problem. In this case, you can actually think of Gamma Correction as a compression problem. If we stored data in linear-space, we would need 16 bits per channel instead of 8 for simple diffuse textures.

Problem 2: Gamma Correction (Monitor Calibration) Most people have horribly calibrated TVs. They are getting better, but we took a big step backwards when the top-of-the-line TVs went from CRTs to LCDs. Most LCDs are way too contrasty. So, there is this problem of “Gamma Correction” where we are trying to calibrate the TV to match the color profile that we expect, which is usually sRGB. That’s what the “Gamma Correction” slider in a game generally does.

This problem includes issues like the NTSC vs. PAL standards, the horrible Xbox 360 PWL gamma curve, etc. But for most end users it’s not a huge deal and there really isn’t a good solution. If you let this one slide, I don’t blame you.

So those are the two problems. Problem 1 is SUPER DUPER IMPORTANT. When I talk about gamma, that’s usually what I’m referring to. It doesn’t matter how bad your end-user’s TV is. You STILL have to do your lighting in linear space which means gamma correcting your textures/framebuffer on read and write.

Problem 2, well, do the best you can but don’t beat yourself up over it.

comments powered by Disqus