Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't always enable GL_FRAMEBUFFER_SRGB #805

Closed
nstoddard opened this issue May 5, 2015 · 4 comments

Comments

@nstoddard
Copy link

commented May 5, 2015

I'm working on an application that uses FXAA. The output didn't look quite right, and it turns out it's because glium is automatically enabling GL_FRAMEBUFFER_SRGB. There doesn't seem to be any way to disable this - I had to modify the glium source code to disable it. There needs to be a way to disable it, or maybe it should be disabled by default and you would provide a draw parameter to enable it.

There's also some systems that don't support GL_FRAMEBUFFER_SRGB, which would cause output on those systems to look bad. Is there a way for glium to detect if it's not supported, and emulate it with a shader instead?

@tomaka

This comment has been minimized.

Copy link
Member

commented May 5, 2015

My idea was to add a flag to programs that tells whether the program outputs sRGB or linear RGB. Glium would disable GL_FRAMEBUFFER_SRGB if the program outputs sRGB, and enable it if it doesn't. Would that make sense?

There's also some systems that don't support GL_FRAMEBUFFER_SRGB, which would cause output on those systems to look bad.

Actually if I'm not mistaken it would look exactly the same.

@tomaka

This comment has been minimized.

Copy link
Member

commented May 5, 2015

Another option for you is to simply render the intermediate image into an SrgbTexture2d instead of a Texture2d.

@nstoddard

This comment has been minimized.

Copy link
Author

commented May 5, 2015

Another option for you is to simply render the intermediate image into an SrgbTexture2d instead of a Texture2d.

I tried this, and unfortunately it doesn't seem to work - the output is exactly the same. I could be doing something wrong though.

My idea was to add a flag to programs that tells whether the program outputs sRGB or linear RGB.

That sounds like it would be fine. Would this be an extra parameter to Program::from_source?

Regarding sRGB not being supported everywhere, I was working on a game a while back that worked fine on my system, but on someone else's system the output was darker than it should be. I think the problem was that the system didn't have sRGB capable framebuffers, so GL_FRAMEBUFFER_SRGB didn't do anything. I ended up having to do the conversion myself in the shaders, with code like out_color = pow(color, vec4(1.0/2.2,1.0/2.2,1.0/2.2,1.0));.

@tomaka

This comment has been minimized.

Copy link
Member

commented May 5, 2015

That sounds like it would be fine. Would this be an extra parameter to Program::from_source?

Actually the flag already exists, I just don't know where to put in in the program creation API.
(the program creation API is still a bit blurry to me because I don't want to close the door to awesome things in the future, like compile-time introspection of the GLSL code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.