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

How: scene.append_with_opacity(scene) #623

Closed
simbleau opened this issue Jul 5, 2024 · 3 comments
Closed

How: scene.append_with_opacity(scene) #623

simbleau opened this issue Jul 5, 2024 · 3 comments

Comments

@simbleau
Copy link
Member

simbleau commented Jul 5, 2024

I have a scenario in bevy_vello I want to provide users the ability to fade the entire scene's opacity.

Take for example, an SVG.

An SVG is a static scene, you could even say it I store it as an Arc<Scene>.

When someone wants to change the opacity of the entire image, how could I draw that opacity? Is there a blend mode that would do the trick?

@raphlinus
Copy link
Contributor

raphlinus commented Jul 11, 2024

What you want here is push_layer, and in particular where you get to specify the alpha. You do need to supply a clip shape, which in many cases can be the axis aligned bounding box enclosing the content.

If you just want an alpha group, then you should use Mix::Normal and Compose::SrcOver. That's not the default, which I can see can cause problems.

A couple of notes. If you nest these deeply (more than 4) you might run into problems with the current implementation, as we don't fully implement the overflow of the blend stack. That's a bug though and if it becomes important we can prioritize it.

Also, I've explored making the clip shape optional. The stack monoid paper explains how to compute blend bounding boxes and there is prototype code there. However, wiring it all up is nontrivial. It's probably easiest to have the application provide the clip shape for now.

@DJMcNab
Copy link
Member

DJMcNab commented Jul 15, 2024

I think we should close this issue, with this answer. We could open a new issue for making the clip shape optional, if needed.

@simbleau
Copy link
Member Author

I implemented this for SVG/Lottie using a fullsize rect as mentioned.

The problem is that raw scenes dont have a size, and therefore no clip shape that makes sense.
But I'd maybe argue if a user is rendering a raw scene with bevy_vello, they can apply opacity how they want themselves.

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

No branches or pull requests

3 participants