-
-
Notifications
You must be signed in to change notification settings - Fork 166
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
sRGBA gamma aware texture sampler #166
Comments
The problem with EXT_sRGB: it is out of "safe webgl1 extensions" list: https://jdashg.github.io/misc/webgl/webgl-feature-levels.html Lets keep it open though and collect some ideas. |
Browser compatibility for EXT_sRGB is pretty good - pretty much every browser out there. Given that Edge is now using the Chrome engine, I expect it will be supported for Edge as well: https://developer.mozilla.org/en-US/docs/Web/API/EXT_sRGB Few ways we could support it:
What problems, if any are there with the approaches above? |
Surprisingly, but people still use edge. Last bug report from the edge user was just couple of month ago. I like the idea of a special texture format that will be SRGB on most platforms, but for some corner case will fall back to plain RGB and colors would be a bit off. However I would try to somehow avoid inconsistency across browsers. Maybe it is worth sarcrificing a little bit of performance and doing SRGB covnersion on the shader side with RGB textures? |
They will actually be a lot off if the shader expects colors in linear space, but gets them in gamma space. One would need to write a separate pipeline for the fallback case, which would be annoying.
sRGBA-aware texture sampling is not only for performance, it is also for quality. A classic RGBA sampler will do bilinear blending in gamma-space, producing the wrong colors when interpolating. An sRGBA aware sampler will do the blending in the correct (linear) space. This is very hard to work around in the shader unless the shader does manual four-tap sampling and interpolation, but then it need to know the resolution of the texture etc. And with mipmaps it gets much worse. Anyway, an sRGBA-aware texture sampler proposed by this issue is probably not that important to most people - the erroneous colors of the current default sampler is only visible when magnifying textures (e.g. when using a coarse texture as gradient). I don't think |
But apparently this would be the case only for the very old edge version, so rendering at least something usable would be better than just a panic, isnt it? However I am not yet sold on that idea, I personally believe that we should guarantee that OpenGL/Metal subset we use will works exactly the same way on all miniquad-supported platforms. And if there is no way to emulate/workaround some certain issue - it is better to not use that feature at all. |
Microsoft is dropping support for the old Edge in 2 months, on March 9, 2021: This means there will be full browser compatibility for supported browsers by the browser vendor. What do you think of officially dropping support for the Old Edge in miniquad?
In my opinion, it's very important for visuals, even if people don't realize. The sRGB can produce many unpleasant artifacts in 2D even sprite rendering without resizing - halos around color, unintended "drop shadow" or "outline" effect for sprites. Here's example from Unity, Linear on top, sRGB compression on bottom. with sRGB we can see serious halos/color issue. For the sizing, there can be serious issue with textures. Some examples to see the texture quality degradation, resized to make 2x smaller: sRGB blending/sizing calculations are always wrong (incidental problem in decades in industry), so when I think of linear vs sRGB I consider "linear" as bug-fix.
I agree with the goal - it will make miniquad simpler. Perhaps we can keep this goal and have linear by dropping support for Old Edge? |
There is a separate issue of how to composite sprites/textures in linear space. The WebGL framebuffer does all blending in the incorrect gamma space (even WebGL2) so the only solution to get that correct is to render-to-texture. It is a bit infuriating how bad WebGL is :) |
Thanks for clarifying! Just to clarify as well - my second set of pictures is for sizing (similar to the issue you mentioned), not blending. I didn't know WebGL2 blends in sRGB, thanks for the info! |
Following up the discussions, we have 3 options:
Opinions? |
I think adding a new To use miniquad as a fully compliant backend for egui (what egui_glium does now) it would also need to support sRGB correct blending, which means the In any case, I don't really have much time to work a switch from glium right now anyway. I mostly created this issue because I think sRGB correct colors is something a lot of projects would like to have. |
But GL_FRAMEBUFFER_SRGB do not really work correctly even on webgl 2 or I am wrong here? (I am looking at this stackoverflow answer, did not researched this myself https://stackoverflow.com/a/51034463) |
I still have a thin hope that But |
Update: Old edge (Edge Legacy) market share is now 0.25%, and Microsoft has stopped support since March 2021
What is other's opinion? |
It would be great if
miniquad
could support theGL_SRGB8_ALPHA8
texture format. This enables sRGBA gamma-aware texture sampler, which is the only way to get colors rights with bilinear filtering (and mipmaps).WebGL1 only supports it with the
EXT_sRGB
extension. WebGL2 supportsGL_SRGB8_ALPHA8
by default.The text was updated successfully, but these errors were encountered: