Discussion:
[Opensg-users] OpenSG2: sRGB and Gamma correction
Johannes Brunen
2015-12-10 13:01:46 UTC
Permalink
Hello,

I would like to write my shader correctly with respect to Gamma correction. After spending some time I see two possible routes for that.

1. Explicitly write the conversions into the shader code, e.g. after texture fetch or before writing the fragment color.
2. Use the OpenGL extensions that provide support for the sRGB color space, i.e. EXT_texture_sRGB and ARB_framebuffer_sRGB.

I would like to apply the second case because it simplifies the shader code and is expected to provide more performance. Is this case supported by OpenSG and if not could we add the missing parts into the framework?

Does anyone know in detail what have be to be done in order to support these two extensions?

Best,
Johannes
Carsten Neumann
2015-12-12 00:02:47 UTC
Permalink
Hello Johannes,

I've not forgotten about the FBO/scissor issue, but I think I can answer
this one without needing to start builds ;)
Post by Johannes Brunen
I would like to write my shader correctly with respect to Gamma
correction. After spending some time I see two possible routes for that.
1. Explicitly write the conversions into the shader code, e.g. after
texture fetch or before writing the fragment color.
2. Use the OpenGL extensions that provide support for the sRGB color
space, i.e. EXT_texture_sRGB and ARB_framebuffer_sRGB.
I would like to apply the second case because it simplifies the shader
code and is expected to provide more performance. Is this case supported
by OpenSG and if not could we add the missing parts into the framework?
It should be possible to make use of EXT_texture_sRGB simply by setting
the ExternalFormat and InternalFormat of a TextureObjChunk to one
defined by the extension.
For a bit more complete support the enum Image::PixelFormat could be
extended to contain the sRGB formats. There may not even be any changes
to the code of TextureObjCunk needed.

Support for ARB_framebuffer_sRGB is mostly needed in the native Window
implementations, since you have to request and sRGB capable framebuffer
from the window system (GLX/WGL/...). Once you have that it is mostly a
matter of calling glEnable(GL_FRAMEBUFFER_SRGB). If you use a
window/context that is not created by OpenSG itself you need to request
the sRGB framebuffer there.
In order to make this work correctly when rendering to FBOs those and
the main Window (i.e. application framebuffer) would need to be made
aware whether they are linear or sRGB so that OpenSG can call
glEnable/glDisable(GL_FRAMEBUFFER_SRGB) as needed. For FBOs OpenSG could
look at the format of the color buffer attachments, but the question
then is what to do when there are multiple and not all have sRGB
formats? I'm not sure what OpenGL actually does in that case or if that
is perhaps a case of FRAMEBUFFER_INCOMPLETE?

Cheers,
Carsten



------------------------------------------------------------------------------
Johannes
2016-01-18 09:05:18 UTC
Permalink
Hello Carsten,
Post by Carsten Neumann
Hello Johannes,
I've not forgotten about the FBO/scissor issue, ...
Sorry for badgering, but one month has passed by and I would like to ask
if you have not forgotten about the FBO/scissor issue?

Best,
Johannes

Loading...