OpenGL: gamma-corrected image does not appear linear

I use OpenGL for rendering, and when I write linear values ​​to a standard framebuffer (without any gamma correction), they seem linear on my monitor. This contradicts everything that I thought about gamma correction (as described here: http://gamedevelopment.tutsplus.com/articles/gamma-correction-and-why-it-matters--gamedev-14466 ). Without gamma correction, I would expect the middle colors to be darkened non-linearly on my monitor.

But here is what I actually see; first without gamma correction on my part, then with gamma correction: enter image description here

Here is my shader fragment without gamma correction (drawn on the full-screen quad-core image by default for the framebuffer). This results in a linear image on the left:

out vec4 fsOut0; void main( void ) { // split the screen into 10 discrete color bands float yResolution = 768.0; int intVal = int(gl_FragCoord.y / yResolution * 10.0); fsOut0.rgb = vec3( float(intVal) / 10.0 ); fsOut0.a = 1.0; } 

And here is a shader with added gamma correction (from linear space to sRGB). This results in a brighter image on the right:

 out vec4 fsOut0; void main( void ) { // split the screen into 10 discrete color bands float yResolution = 768.0; int intVal = int(gl_FragCoord.y / yResolution * 10.0); fsOut0.rgb = vec3( float(intVal) / 10.0 ); // gamma correction fsOut0.rgb = pow( fsOut0.rgb, vec3(1.0/2.2) ); fsOut0.a = 1.0; } 

I check if the colors are linear by simply looking at them and using the color set in Photoshop and looking at the differences in RGB values ​​between the color bars. For a linear-looking image, the difference between each color is (mostly) constant.

I also tried requesting an sRGB framebuffer. In this case, recording linear values ​​without gamma correction looks like a second image (non-linear).

What am I doing wrong? Or maybe my two monitors are both distorted and that Photoshop does not select colors in linear space? Or is my “non-linear” image really the correct linear result, but it just doesn't seem linear to my eyes?

My question is what duplicates: Is gamma necessary to correct the final color on a modern computer / monitor Unfortunately, the accepted answer is extremely confusing, and its parts that I could track seem contradictory or at least not fully explained to someone less knowledgeable than the defendant.

+5
source share
1 answer

Well, both your left and right photos, as you would expect. They are beautiful, and yes, I know my things.

It’s just that our eyes are also not very linear, for example, 1/5 of linear intensity (light intensity) is perceived as “half bright, like white”. This is what you see on the right, in the corrected image, below.

This is the reason that gamma is present in the first place - to help encode by mimicking the eye response. IOW, gamma makes linear linear jump linear.

However, the physically linear ramp (as on the right), therefore, is completely not perceived as linear. Remember that the real world has a rather large dynamic range (in terms of light intensity), and our eyes compensate for this. This is confusing, but unlike many others, you really got the numbers right.

+1
source

Source: https://habr.com/ru/post/1215725/


All Articles