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

Atlas Opacity #2528

Closed
nathan-ahn opened this issue Jul 11, 2024 · 3 comments
Closed

Atlas Opacity #2528

nathan-ahn opened this issue Jul 11, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@nathan-ahn
Copy link

Description

Description

I believe Atlas could cover a wider range of use-cases with support for individual opacity. I've done some experimentation, and as far as I can tell, it's not possible even with creative usage of colors and blendMode. (Closest I've gotten was setting colors using rgba(255, 255, 255, ${opacity}) and blendMode="srcOut", but that loses the opacity of the original texture).

If this is possible, I'd be happy to help out with a pull request with guidance.

Thanks as always for all the awesome work on this package!

@nathan-ahn nathan-ahn added the enhancement New feature or request label Jul 11, 2024
@wcandillon
Copy link
Contributor

Could the issue be that colors are expected to be premultiplied? e.g: rgba(${255 * opacity}, ${255 * opacity}, ${255 * opacity}, ${opacity}). I'm closing it for now but let me know if that doesn't fix the issue.

@sergeymorkovkin
Copy link

sergeymorkovkin commented Jan 9, 2025

@wcandillon Same here.

I've built a prototype and my results are exactly as @nathan-ahn mentioned: blendMode = srcOut used along with any color uses color alpha channel for specifying opacity of an individual sprite, but when sprites overlap, next rendered sprite completely overrides previously rendered one.

I've tried both: managed expo and prebuilt skia: 1.5.0 and 1.8.2 respectively, but results were the same. #2809

I've also tried attaching a shader to atlas, but that didn't work either - shader has been completely ignored. So, I'm assuming, atlas is using it's own shaders that don't let any other shaders to come into play (not sure of that, just an assumption). Or maybe I were attaching it in a wrong way.

So, what would be a better approach to implement call batching for sprites? Maybe, a custom blending mode? Or maybe a custom fragment shader? And, by the way, does Skia have call batching on it's own?

@wcandillon Kindly advice.

Image

@sergeymorkovkin
Copy link

@wcandillon William, I'm willing to contribute into this too, if possible. Pre-multiplied colors didn't work, unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants