1
\$\begingroup\$

I'm currently reading about the topic of gamma correction and am a bit confused about what should I, as a game developer, do about it. There seem to be a few options here:

  1. Don't do anything at all and let OS, driver, monitor and user figure it out. Doesn't seem to be the right one to me, but I may be wrong.
  2. Explicitly request sRGB framebuffer and enable GL_FRAMEBUFFER_SRGB while doing rendering to display, leaving details to driver once again.
  3. Explicitly request sRGB framebuffer and manually apply gamma correction in shader, potentially exposing slider to user.

In addition to above, there's an idea to "uncorrect" textures, which assumes that they were made in sRGB color space to begin with, which seems pretty dubious to me: wouldn't good textures already be properly using RGB colorspace instead of sRGB? Even if they weren't, why not correct them on disk instead of doing extra calculations in runtime?

So, what approach should I take?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ It's common for files to be saved in sRGB colour space, because this preserves precision in dark colours that would otherwise be lost if storing in linear RGB, leading to visible banding in dark parts of the image. \$\endgroup\$
    – DMGregory
    Jun 5, 2021 at 15:53

1 Answer 1

1
\$\begingroup\$

Ask OpenGL driver if it has extensions for framebuffer and texture sRGB conversions. And implement fallback gamma correction with #ifdef in shader code.

You must also notice that not every texture is in sRGB space, for example normal maps. And if you do postprocessing of your image, you should convert from linear space to sRGB only on last stage.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .