Re:The Book of Shaders
by socialist_coder on Tuesday March 17, 2015 @08:54AM
(#9217538)
So you're saying that in my shaders, as long as I have GL_FRAMEBUFFER_SRGB enabled, this conversion takes place automatically? Am I understanding the docs right?
I'm asking because I'm a mobile game developer using Unity3d, and we have a fair amount of custom shaders, and I've never heard about this sRGB vs RGB colorspace thing before so I want to investigate. There's not much on google for GL_FRAMEBUFFER_SRGB + Unity3d. Maybe it's handled automatically or it's not even possible with openGL ES 2.0.
The implicit conversion only happens when the internal format of the destination buffer is GL_SRGB8 or GL_SRGB8_ALPHA8
Here's a bunch of shader code and examples for different tone-mapping operators. I really like the Hejl/Burgess-Dawson one as a simple Linear -> sRGRB-ish output function.
Edit 2: And of course when you load textures you must tell OpenGL they're in sRGB colourspace (most probably they are, if you created them on a normal monitor), so it will do the reverse transformation when reading from the texture. All this trouble could have been avoided if monitors were 30bit linear RGB colourspace to begin with, but that's history now. C'est la vie.