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

Fix alpha blending in WebGL backends #650

Merged
merged 10 commits into from
Aug 25, 2021
Merged

Fix alpha blending in WebGL backends #650

merged 10 commits into from
Aug 25, 2021

Conversation

AsmPrgmC3
Copy link
Contributor

This fixes alpha blending in the WebGL backends by first blending everything in a linear framebuffer, before converting the result to sRGB in a second shader.

The results of the color test are now identical to the egui_glium backend when using the WebGL2 backend.
The WebGL1 backend suffers from reduced precision in dark colors without the SRGB8_ALPHA8 format and still doesn't have correct texture interpolation.

Color test with the change (I have since removed the warning):
WebGL2
WebGL2
WebGL1
WebGL1

(Sorry for not following the contributing guidelines exactly ("First file an issue" and all that). This was a spontaneous test as I didn't know whether it was even possible and I didn't wan't to file an issue the same minute as closing it (Should I?).)

Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wonderful work; thank you so much!

As I noted in my review I think the WebGL1 pipeline should remain as it was, but the improvements to the WebGL2 renderer is massive, and works great! ❤️

egui_web/src/shader/main_fragment_100es.glsl Outdated Show resolved Hide resolved
egui_web/src/webgl1.rs Outdated Show resolved Hide resolved
egui_demo_lib/src/apps/color_test.rs Show resolved Hide resolved
epaint/src/texture_atlas.rs Outdated Show resolved Hide resolved
@emilk emilk merged commit 31a1882 into emilk:master Aug 25, 2021
@emilk
Copy link
Owner

emilk commented Aug 25, 2021

Thank you again!

mankinskin pushed a commit to mankinskin/egui that referenced this pull request Sep 29, 2021
Add a render-to-texture step with an sRGBA8 texture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants