Skip to content

Fix alpha blending in WebGL backends - #650

Merged
emilk merged 10 commits into
emilk:masterfrom
AsmPrgmC3:master
Aug 25, 2021
Merged

emilk merged 10 commits into
emilk:masterfrom
AsmPrgmC3:master

Conversation

@AsmPrgmC3

Copy link
Copy Markdown
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?).)

@emilk emilk left a comment

Copy link
Copy Markdown
Owner

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! ❤️

Comment thread egui_web/src/shader/main_fragment_100es.glsl Outdated
Comment thread egui_web/src/webgl1.rs Outdated
Comment thread egui_demo_lib/src/apps/color_test.rs
Comment thread epaint/src/texture_atlas.rs Outdated
AsmPrgmC3 and others added 2 commits August 25, 2021 18:26
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
@emilk
emilk merged commit 31a1882 into emilk:master Aug 25, 2021
@emilk

emilk commented Aug 25, 2021

Copy link
Copy Markdown
Owner

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

2 participants