sRGB and gamma correction in Java3d

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

sRGB and gamma correction in Java3d

jimzuber
I see a number of references in the Java3d documentation that "Java 3D assumes that a linear (gamma-corrected) visual is used for all colors." I assume that this means that Java3d assumes that images loaded (i.e. textureloader) contain linear RGB and not sRGB. If that is the case, what I am not clear about is once all the texturing and/or blending occurs, does Java3d convert the linear RGB  to sRGB prior to rendering it on a monitor. Most monitors assume sRGB imput data not linear RGB. If Java3d is displaying linear RGB to a monitor that assumes it is sRGB, the colors will be off.

Is my understanding above correct and if so, is there a way to gamma encode the linear RGB before Java3D renders it?

Any input would be helpful.

Jim



Reply | Threaded
Open this post in threaded view
|

Re: sRGB and gamma correction in Java3d

gouessej
Administrator
Hey

You can build your own textures with your own image components and it allows to specify the format and the filters (mignification and magnification). The texture loader uses the RGBA format by default but lots of other formats are supported:
http://jogamp.org/deployment/java3d/1.6.0-final/j3dutils/javadoc/com/sun/j3d/utils/image/TextureLoader.html
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: sRGB and gamma correction in Java3d

jimzuber
Thanks for the quick response. Unfortunately none of the supported formats for texture loader is sRGB. Obviously I can convert the sRGB image to linear RGB before using the texture loader with format RGBA. If I do that, I am confident that the blending will occur in linear space, which is what I need to happen My real question is that happens on the output rendering side. Does the linear RGB just get sent to the monitor? And if so, is there a way to intercept it to convert it back to sRGB before the monitor gets in when Java3d is rendering the image.
Reply | Threaded
Open this post in threaded view
|

Re: sRGB and gamma correction in Java3d

gouessej
Administrator
I don't think that the JOGL pipeline of Java3D uses GL_EXT_texture_sRGB, maybe Harvey and Phil can confirm. I assume that we just send the linear RGB.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: sRGB and gamma correction in Java3d

philjord
Jim,
This is a great question and I'm fairly embarrassed to say I had no real idea how sRGB was handled until you asked this question.

The reason for that (I've discovered) is that S3TC compressed images don't separately express that they are sRGB and these are the images I've worked with mainly (through an extension to Java3D that's available in Java3D 1.7).
See issue 9 here:
https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB.txt 

The open GL definition for Images states they are linear unless the GL_EXT_texture_sRGB is available
https://www.khronos.org/opengl/wiki/Image_Format
The JoglPipeline in Java3D does not query for nor use that extension.

So loading and  blending entirely in linear space is appropriate.

For more on how the fixed pipeline loads images see
https://github.com/philjord/java3d-core/blob/master/src/main/java/org/jogamp/java3d/JoglPipeline.java#L5656

For the programmable equivalent see
https://github.com/philjord/java3d-core/blob/master/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java#L5717