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

commit that adds pre-multiplied to images, also changes alpha for colored container? #180

Open
cybersoulK opened this issue Jul 14, 2024 · 12 comments · May be fixed by #198
Open

commit that adds pre-multiplied to images, also changes alpha for colored container? #180

cybersoulK opened this issue Jul 14, 2024 · 12 comments · May be fixed by #198
Labels
bug Something isn't working

Comments

@cybersoulK
Copy link
Contributor

cybersoulK commented Jul 14, 2024

f893ad1

image image

The first image is before the commit, second is after the commit.
The elements are colored_box and colored_box_container

@LPGhatguy LPGhatguy added the bug Something isn't working label Jul 15, 2024
@LPGhatguy
Copy link
Member

Interesting! This should be an easy fix and probably impacts our game too.

@msparkles
Copy link
Contributor

@LPGhatguy we're noticing in #179 that the coloured texts are already premul'd (at least as far as we can tell)

We also found a really bad performance issue in the alpha premultiplication.

We're committing a fix for those because it heavily affects coloured texts, it takes like 5s to write 3 coloured text characters on release right now, Oops!

@msparkles
Copy link
Contributor

P.S. We ran a profiler on yakui example to see that premul'd alpha really is taking too long. It's all on .round()

@LPGhatguy
Copy link
Member

@msparkles Those changes seem useful even outside of cosmic text. If the conversion that removes round is the same, I'd take that in a separate PR.

I wonder where the best place to handle the premultiplication in the pipeline is.

@msparkles
Copy link
Contributor

Should we cherry-pick them into a separate branch?

@LPGhatguy
Copy link
Member

Did this end up fixed as part of the cosmic text PR?

@cybersoulK
Copy link
Contributor Author

cybersoulK commented Dec 20, 2024

I haven't updated winit since 0.30. is there a way i could test?
using yakui rev = "ec96d2461374bb84042790c7474c6b16321d488f"

@cybersoulK
Copy link
Contributor Author

cybersoulK commented Dec 21, 2024

image

I put some effort into upgrading.
Unfortunately, it doesn't seem like branch main has fixed the issue.

Additionally several colored box layouts and buttons seem to have gotten broken after this commit:
7205a74

image

@cybersoulK
Copy link
Contributor Author

I determine the color like so
colored_box_container(Color::rgba(20, 20, 50, 100))

The pipeline uses pre multiplied alpha.

blend: Some(wgpu::BlendState::PREMULTIPLIED_ALPHA_BLENDING),

So i guess colored box needs to be premultiplied by yakui somewhere before the rendering.

@cybersoulK
Copy link
Contributor Author

A quick fork and change PREMULTIPLIED_ALPHA_BLENDING to ALPHA_BLENDING, and even removing
let texture = premultiply_alpha(texture); hasn't reverted to the initial color. 🤷‍♂️

@LPGhatguy
Copy link
Member

Super odd, this is something to look into. I imagine it's affecting our game as well but not to the same extent.

@cybersoulK cybersoulK linked a pull request Dec 24, 2024 that will close this issue
@cybersoulK
Copy link
Contributor Author

I just went back to review the commit and found a silly error. doing A/B testing the colors look the same with this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants