Gamma

From vegard.wiki
Revision as of 06:42, 19 December 2019 by Vegard (talk | contribs) (new page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Quick rules of thumb, since I can never remember which is which:

  • RGB = linear space
  • sRGB = gamma space
  • most image files store sRGB
  • sRGB is unfit for blending

The corollary is:

  • Image files loaded as textures should be converted from sRGB to RGB (but some decoders do this for you!)
  • The shader responsible for putting the final pixels on the screen should have a gamma correction step doing:
const float gamma = 2.2;

out vec4 color;

void main()
{
    // ...

    color = pow(color, 1. / gamma);
}

See also