Page 1 of 1

Layered Sprites With Transparency

PostPosted: Fri Nov 09, 2018 7:22 pm
by JosephHorsmann
Hello,

I'm new to Amplify and still wrapping my head around how transparency is handled. I'm currently looking at making a shader with multiple PNG sprites with transparency layered on top on each other. I've experimented with add & multiply, as well as different blend types & modes and have yet to find success.

What I would like to achieve as a result is simply for one texture to sit on top of another, without blending in any way, as seen below:
PIC 1.png
PIC 1.png (5.87 KiB) Viewed 1438 times


I want to avoid masking or blending, like this example:
PIC 2.png
PIC 2.png (5.42 KiB) Viewed 1438 times

Any idea how to accomplish this? I feel like it should be possible, but I can only seem to find nodes & settings that will blend, instead of layering on top of, like I am trying to.

Re: Layered Sprites With Transparency

PostPosted: Mon Nov 12, 2018 4:36 pm
by Amplify_Borba
Hello, one possible way to accomplish this is through setting up a mask as the interpolator for a Lerp node, please refer to the example below:

Image

I'm using the relay node to show a preview of the mask being used, which has a value of 0 or black where the A input's texture is present, and 1 or white for the B input's texture.

You can also check out our SingleChannelMasking sample for a more complex case in which several masks are used, as well as the SpriteMask or MaskedUI samples for examples using each of those specific templates.

Please let me know if this helps!

Re: Layered Sprites With Transparency

PostPosted: Mon Nov 12, 2018 5:06 pm
by JosephHorsmann
Thanks for the reply Amplify_Borba,

Your example does help. I didn't realize that the alpha input of the lerp node worked that way. The lerp node will allow me to do what I need to do.

Re: Layered Sprites With Transparency

PostPosted: Tue Nov 13, 2018 8:50 am
by Amplify_Borba
Glad I could help!

Have you had the chance to rate and review Amplify Shader Editor? It would be awesome if you could share your experience with the Unity community, every bit helps, your feedback is extremely valuable to us.

Please feel free to get back in touch if you have any further issues or questions.