问题
I am working on a OpenGL ES 3.0 Android project using Java. I need to implement gamma correction and somewhere I've read that sRGB textures would be supported in OpenGL ES 3.0. So my intention was to call glEnable(GL_FRAMEBUFFER_SRGB) before rendering into the default framebuffer.
However, when I try to call
GLES30.glEnable(GLES30.GL_FRAMEBUFFER_SRGB)
it turns out, there is no GLES30.GL_FRAMEBUFFER_SRGB, but there are some constants for sRGB texture formats like GLES30.GL_SRGB.
So, my question is: is it possible to let OpenGL ES 3.0 do the gamma correction for me? If yes, how?
Otherwise, I guess, I'll have to do gamma correction manually.
回答1:
I realize that this question is 2 months old, but since it came up in Google, I guess I would post an answer for future googlers :)
GL_FRAMEBUFFER_SRGB seems to only be available on OpenGL desktop, and through extensions on OpenGLES 2.0. But through experimentations (I'm currently working on this subject) I realized that on OpenGLES 3.x, whenever the texture underlying a frame buffer has an sRGB format, colors are correctly (and automatically) converted to sRGB when writing to the frame buffer. So you don't need to use GL_FRAMEBUFFER_SRGB to enable sRGB conversion when rendering to an sRGB texture.
Now if you write directly to the back buffer, you might have options to enable sRGB writes, but that would be controlled on the application side (for instance on Windows it's a flag that you specify when creating your context through wgl if I'm not mistaken) Unfortunately I can't confirm this since in the framework I'm working on, I don't have access to this part.
来源:https://stackoverflow.com/questions/27024884/srgb-framebuffer-on-opengl-es-3-0