So, i stumbled upon the topic of gamma correction.
https://learnopengl.com/Advanced-Lighting/Gamma-Correction
So from what i've been able to gather: (Please correct me if i'm wrong)
- Old CRT monitors couldn't display color linearly, that's why gamma correction was nessecary.
- Modern LCD/LED monitors don't have this issue anymore but apply gamma correction anyway. (For compatibility reasons? Can this be disabled?)
- All games have to apply gamma correction? (unsure about that)
- All textures stored in file formats (.png for example) are essentially stored in SRGB color space (as what we see on the monitor is skewed due to gamma correction. So the pixel information is the same, the percieved colors are just wrong.)
- This makes textures loaded into the GL_RGB format non linear, thus all lighting calculations are wrong
- You have to always use the GL_SRGB format to gamma correct/linearise textures which are in SRGB format
Now, i'm kinda confused how to proceed with applying gamma correction in OpenGL.
First of, how can i check if my Monitor is applying gamma correction? I noticed in my monitor settings that my color format is set to "RGB" (can't modify it though.) I'm connected to my PC via a HDMI cable. I'm also using the full RGB range (0-255, not the 16 to ~240 range)
What i tried to do is to apply a gamma correction shader shown in the tutorial above which looks essentially like this: (it's a postprocess shader which is applied at the end of the renderpipeline)
vec3 gammaCorrection(vec3 color){
// gamma correction
color = pow(color, vec3(1.0/2.2));
return color;
}
void main()
{
vec3 color;
vec3 tex = texture2D(texture_diffuse, vTexcoord).rgb;
color = gammaCorrection(tex);
outputF = vec4(color,1.0f);
}
The results look like this:
No gamma correction:
With gamma correction:
The colors in the gamma corrected image look really wased out. (To the point that it's damn ugly. As if someone overlayed a white half transparent texture. I want the colors to pop.)
Do i have to change the textures from GL_RGB to GL_SRGB in order to gamma correct them in addition to applying the post process gamma correction shader? Do i have to do the same thing with all FBOs? Or is this washed out look the intended behaviour?