Gamma correction in OpenGL

Started by
11 comments, last by Triad_prague 12 years, 5 months ago
Maybe I'm not getting this right, but isn't proper gamma correction in OpenGL as much as using the *_SRGB constant for defining textures (to convert to linear space), and creating a SRGB framebuffer (to convert back)?

This is something I understand runs completely in hardware nowadays without any special tweaks needed (and, also in absence of shaders).
Advertisement
Old games (
of course I'm talking about Windows), use http://msdn.microsoft.com/en-us/library/dd372194%28VS.85%29.aspx
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Gamma correction is a non-linear operation, so I doubt that you can do it with additive or subtractive blending or even another blending.

However, I'd say that gamma correction shouldn't be looked at in OpenGL at all. IMHO it is part of the windowing system or monitor device settings.


This article explains why you should perform your color blending in linear space.
I updated my engine to use linear lighting and it really made a difference. The colors are much more realistic now.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Thanks guys, in the end I finally cheat and use SDL gamma functions to do the work hehe sorry to bother you all :P
the hardest part is the beginning...

This topic is closed to new replies.

Advertisement