Search code examples
openglsrgb

When should I use GL_SRGB8 instead of GL_RGB8?


With respect to RGB and sRGB, are the following understandings I have (or not) true?

  1. I read an authored image (a .png) into a GL_SRGB8 format texture.
    • (q) When sampling the texture from (1) the hardware will convert from sRGB to linear colour space?
  2. I read an authored image into a GL_RGB8 texture.
    • (q) When sampling the texture from (2) the hardware will not convert from sRGB to linear?
  3. I set GL_FRAMEBUFFER_SRGB to true at the final stage of my pipeline.
    • (q) When displaying the back buffer the hardware will convert from linear to sRGB colour space?
  4. I have a pipeline with 5 stages, each writing to a floating point texture (GL_RGBA16F)
    • (q) The whole pipeline is linear until the final stage, provided (1) and (3) are true.

Solution

  • Essentially yes to all of them. However (3) has an additional constraint: For a framebuffer to do linear RGB to sRGB conversion, the color attachment must be in SRGB format itself, i.e. be a sRGB texture, renderbuffer or a main window with a sRGB pixelformat.