Advertisement Jump to content
Sign in to follow this  

Is GL_FRAMEBUFFER_SRGB global state or per framebuffer(object)?

This topic is 1802 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is GL_FRAMEBUFFER_SRGB global state or applies specifically to the currently bound framebuffer(object)?

Share this post

Link to post
Share on other sites


You first need to create your frame-buffer using the GL_SRGB8 or GL_SRGB8_ALPHA8 formats.


Then, GL_FRAMEBUFFER_SRGB that can be used to disable linear->sRGB conversions.

If GL_FRAMEBUFFER_SRGB is disabled, then linear->sRGB conversion of pixel shader outputs is never performed.

if GL_FRAMEBUFFER_SRGB is enabled, then linear->sRGB conversion of pixel shader outputs is performed if the framebuffer was created with an sRGB format.

Share this post

Link to post
Share on other sites

This is best learned from either ARB_framebuffer_sRGB extension spec or from the wording of the core specification. Both state it like this:


If FRAMEBUFFER_SRGB is enabled and the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the framebuffer attachment corresponding to the destination buffer is SRGB (see section 9.2.3), the R, G, and B destination color values (after conversion from fixed-point to floating-point) are considered to be encoded for the sRGB color space and hence must be linearized prior to their use in blending. Each R, G, and B component is converted in the same fashion described for sRGB texture components in section 8.23.

If FRAMEBUFFER_SRGB is disabled or the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING is not SRGB, no linearization is performed. The resulting linearized R, G, and B and unmodified A values are recombined


Also note the comments section in the extension spec (always worth reading these!):

3) Should the ability to support sRGB framebuffer update and blending be an attribute of the framebuffer?
RESOLVED: Yes. It should be a capability of some pixel formats (mostly likely just RGB8 and RGBA8) that says sRGB blending can be enabled.

This allows an implementation to simply mark the existing RGB8 and RGBA8 pixel formats as supporting sRGB blending and then just provide the functionality for sRGB update and blending for such formats.
sRGB support for floating-point formats makes little sense because [blah blah]  support for all fixed-point buffers [...] would require special sRGB conversion hardware.


14) How is the constant blend color handled for sRGB framebuffers?
RESOLVED: The constant blend color is specified as four floating-point values. Given that the texture border color can be specified at such high precision, it is always treated as a linear RGBA value.
Edited by samoth

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!