Sign in to follow this  
Followers 0
Prune

Is GL_FRAMEBUFFER_SRGB global state or per framebuffer(object)?

2 posts in this topic

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

0

Share this post


Link to post
Share on other sites

AFAIK:

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.

2

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
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0