-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Use sRGBA unaware textures, and let the GPU interpolate in sRGB space. #5839
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
base: main
Are you sure you want to change the base?
Conversation
Preview available at https://egui-pr-preview.github.io/pr/5839-bugfix-srgb-interpolate-textures |
Interesting! I would love to see if this does anything for text sharpness |
Yes, I saw your other PR on that topic and at some point was also experimenting with changes to the encoding there, but then figured to keep the two separate. I consider this here more a correctness fix, enabling proper calibration (your CL) afterwards. |
Unfortunately don't have time right now and in the coming days to delve deeper into this but it seems to me more and more that we want to be content aware: |
this one might have been posted somewhere already probably, but love this take 😄 (as a bit of counterpoint to what I wrote above)
... but in the end that's what is causing the ringing as also shown there so there's that :/ |
No need to rush from my side :) And don't get me wrong, even though that might not be obvious from my last couple comments here, coming from 3D rendering, ideologically I'm very much in the "math in linear space" camp 😅. My main priority here is to fix obvious rendering artifacts, and if I'm pushing for "math in gamma space", then it's because:
Regarding the ringing we see here: It's not because we do either gamma or linear interpolation. It's because we do linear interpolation wrong 🙈 We rely on the automatic GPU conversion upon read/write, which assumes non-premultiplied values, which, well, is not the case :P |
PS: I'm also wondering if we should treat "image textures" and "font/shape atlas textures" separately. Image textures contain colors, with all the headache that entails. The atlas textures (which could actually be cut down in size to 1/4) contain "pixel coverage", which we might or might not want to treat differently, see: for example https://hikogui.org/2022/10/24/the-trouble-with-anti-aliasing.html |
With the new parley work, the font atlas texture will be full color (in order to support color emojis): #5784 |
This is one potential fix to the issues we are seeing around GPU texture interpolation of semi-transparent values:
With this change:


Without:
More
Note that this intentionally switches texture interpolation from linear to gamma. On one hand this makes interpolation more consistent with how it is done everywhere else in egui (vertex blending, and cpu computations). On the other hand it breaks a current assumption (see the screenshot from the rendering demo app).
If linear texture interpolation is not necessary, I think this is our best option, and I want to put it forward for discussion. See below for alternatives.
Alternatives that allow for linear blending:
Missing:
Related: