Gamma space or linear space in OpenGL

Hello,

I’ve read a bunch of article about the “correct” pipeline for OpenGL regarding the color management in the fragment shader. But looking at the openframeworks code I can’t find if the texture are loaded in the GPU in gamma space (sRGB) or linear space (RGB). Indeed, depending how it’s loaded the fragment shader will be different.

Anyone can help me about that ? or discuss ?

Thanks a lot !

Nobody know in which color space texture are loaded ? or at least a track where i can dig ?

we don’t touch the colorspace by default which usually means that textures are loaded in gamma space. if you are not doing any processing on them then that’s correct if you are doing lighting calculations for example you should convert textures to linear space and after doing all the calculations go back to gamma space before displaying them or even better do some kind of tone mapping.

ofMaterial still don’t support that kind of pipeline and all the calculations are done in gamma space

As always, thank you very much Arturo for your explanation !
Just two points:

  • why the light calculation with texture is done in gamma and not linear : lack of time to dev OF ? performance ? compatibility ?
  • I noticed in the programmableRender that the texture is not combined with the ambient material and the texture is not combined with the diffuse material too : is it a classic behavior ? in my mind the texture mut be combined with all the light (unless you use specific ambient map / diffuse map / specular map).

Again, thank you !!

  • why the light calculation with texture is done in gamma and not linear : lack of time to dev OF ? performance ? compatibility ?

Yes we haven’t implemented it yet.

  • I noticed in the programmableRender that the texture is not combined with the ambient material and the texture is not combined with the diffuse material too

Both are combined with the texture, in the ofMaterial shader:

vec4 localColor = vec4(ambient,1.0) * tex * v_color + vec4(diffuse,1.0) * tex * v_color + vec4(specular,1.0) * mat_specular + mat_emissive;

Thanks for your reply.

Not a big problem, but in the OF version downloaded from openframeworks.cc, the line you mention is like this :

vec4 localColor = vec4(ambient,1.0) * mat_ambient + vec4(diffuse,1.0) * tex + vec4(specular,1.0) * mat_specular + mat_emissive;

I really have to grab the last version on github :slight_smile: