-
Notifications
You must be signed in to change notification settings - Fork 669
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
WebGL linear backbuffer and wide gamut output #2474
Comments
Ability to specify pixel format of the default framebuffer with wider channels than RGBA8 may be beneficial too, I think. |
This keeps coming up every few months, would be great to have native support for this. |
Actually WebGL has a "linear" backbuffer which is why no conversion is done to the fragment shader outputs. I put linear in inverted commas because no conversion is done between the backbuffer and the display so whatever values are written are interpreted as in the display's color space as @juj noted. A true linear backbuffer would have an sRGB or display encoding step between the buffer and the display. What are not currently supported by WebGL and should be are sRGB framebuffers where the hardware does sRGB encoding of the fragment shader outputs. This would be seemingly trivial to support, given virtually all hardware does it today, and would avoid applications having to do encoding in their fragment shaders. It would also provide correct blending results, something impossible to achieve today. Backbuffer content must be converted to linear before blending then converted back again. If WebGL did provide a true linear 8-bit backbuffer there is a good chance the people making the requests @juj is hearing would be unhappy because they would start to see banding in their results especially if using blending. I think what they really want are sRGB framebuffers. |
They technically exist via an extension for WebGL 1.0 and as a part of WebGL 2.0 core, but only as FBO attachments. There's no way to explicitly set the transfer function of the backbuffer, though. Still, it's probably possible to have hardware-based sRGB conversion for output in WebGL 2.0:
|
@lexaknyazev that's clever but probably expensive in terms of memory bandwidth. Discussions are actively ongoing about how to specify the color space and bit depth of canvases' backing stores. The current proposal is here: https://github.com/WICG/canvas-color-space more specifically: https://github.com/WICG/canvas-color-space/blob/master/CanvasColorSpaceProposal.md Please review, comment and file any issues you see. Thanks! |
Yeah, I'd prefer something like blit operation with sRGB conversion disabled or low-level buffer-style renderbuffer copy. Anyway, there are two issues here:
For now, the most optimal way of color-correct rendering with blending seems to be:
@kenrussell that WICG repo and its linked discourse forum look stalled. Where should issues be filed? |
Please file issues or put up pull requests again on https://github.com/WICG/canvas-color-space . I'll try to help ensure the appropriate people look at them and respond. |
Since the output canvas gets further composited by browser, it should be kept in linear alpha-premultiplied form, and converted to screen colour space by the browser only once it is finished with all the composition. Central issues:
Most existing software use "linear" processing, completely ignoring these issues although they actually work in non-linear in display device's colour space. Doing it properly will necessarily affect existing software, and could only be partially hidden behind a configuration option. |
Currently, all output of WebGL rendering is either treated as if it's in sRGB or in the display's color space (depending on browser and OS). That is, no conversion is done between fragment shader output and the values sent to the screen.
For linear rendering pipelines - in which rendering is done in linear space - it would be beneficial for engines/applications to be able to output their rendering results from the fragment shader in linear space, and have this remapped this into the display's color space. Currently, the application must do its own conversion from linear space to sRGB. (Plus this doesn't allow applications to take advantage of wide-gamut displays.)
For Canvas, a color space proposal exists here:
https://github.com/WICG/canvas-color-space/blob/master/CanvasColorSpaceProposal.md
I expect that color space support will be added to WebGL canvases in a very similar way.
The text was updated successfully, but these errors were encountered: