#How to apply post-processing to specific components (entities) without affecting others?
23 messages · Page 1 of 1 (latest)
Thank you very much, this is the solution. However, doing this will require a lot of cameras. I'm wondering if there are any other solutions.
I'd say it depends how much is going on in the scene. Can you provide a drawing or say a little about how many post processing setups you envision? Are the same post processor with different parameters? Does the post processor follow an entity? Or is it fixed to one area of the screen always?
Please wait while I describe it in more detail.
What I want to implement is the filter effects from Adobe Animate, as shown in the image below. In Flash, a complex sprite is made up of many basic shapes. In Bevy, I use many Mesh2d to combine and render the sprite. I have already implemented Flash animation rendering, where each basic shape can have various filter effects, and each shape has different filter parameters, as shown in the image. I apologize for the image being in Chinese.
Hi, I finally have time to reply.
I see. Are you using your own material and shader or the Sprite component?
I can understand your hesitation at using multiple cameras for this. It could be A LOT of cameras. It seems to me that you'd want to try and do your post processing in your sprite material. Problem is Sprite does not have a custom material available. So you'd have to go back to Mesh2d or perhaps you're already doing that, are you?
Ok. **Another idea: **What if you take your post processing layer, and feed it your rectangles/areas of interest. Basically your sprites that require post processing. No rectangles, no post processing. That avoids having multiple cameras and custom shaders for every sprite. And you get compositing with what's on the screen, which custom sprite shaders wouldn't really be able to do.
I've completed the basic
rendering using Mesh2d and custom shaders. However, the filter effects require post-processing to be applied (I'm not sure if there are other ways to achieve this).
I'm very sorry, I didn't understand what you meant.
Imagine we take the post processing shader and add a value horizontal from [0, 1]. With horizontal set to 0.5, the post processing effect only applies to the left side of the screen. On the right side, it passes through as if there were no post processing effect.
Now elaborate on that so you’ll have a list of regions where you’ll do the post processing effect. If no regions are given, no effect appears.
That's a great explanation, I understand now. However, I think it might be difficult to implement because the final effect is an animation.
Woah. Very cool! Can you show where the effect would happen on 1 or 2 frames?
Now I use Ruffle to display the filter effects. For this animation, the filter effects are applied at the marked positions.
I see. So I suggested simple shapes but maybe it’d be more flexible if you had your post processing accept a texture as a mask. Then you could use one of the rgba channels for your post processing effect; you can have some gradations that way [0, 1]. You’d have to have a few extra cameras but a fixed number: post processing effect count / 4.
I’d suggest adding a sprite parented to the original that only draws to that camera on that one channel. Red for Glow, Green for Blur, etc.
I've consulted the materials. There are only four representations for RGBA, and the quantity is insufficient.
How many post processing effects do you envision needing?
There are seven of them.
Cool. Then I’d suggest using two extra cameras to capture two textures that gives you eight channels. If instead you can do it with a bitmask—no gradations, then an R8 image would be sufficient with 1 camera.
Hmmm... After I check out the information, I have a feeling I won't be able to do this technique.
Thank you so much for the wonderful instructions, I will try to learn to try to do this!
You’re welcome. Good luck!