How to do it...

Adding gamma correction to an OpenGL program can be as simple as carrying out the following steps:

  1. Set up a uniform variable named Gamma and set it to an appropriate value for your system.
  2. Use the following code or something similar in a fragment shader:
vec3 color = lightingModel( ... ); 
FragColor = vec4( pow( color, vec3(1.0/Gamma) ), 1.0 ); 

If your shader involves texture data, care must be taken to make sure that the texture data is not already gamma-corrected so that you don't apply gamma correction twice (refer to the There's more... section of this recipe).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.40.53