Layered Sprites With Transparency

Node-based Shader Editor
Post Reply
JosephHorsmann
Posts: 10
Joined: Mon Oct 08, 2018 2:32 pm

Layered Sprites With Transparency

Post 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.86 KiB) Viewed 3580 times
I want to avoid masking or blending, like this example:
PIC 2.png
PIC 2.png (5.4 KiB) Viewed 3580 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.
User avatar
Amplify_Borba
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Layered Sprites With Transparency

Post 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!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
JosephHorsmann
Posts: 10
Joined: Mon Oct 08, 2018 2:32 pm

Re: Layered Sprites With Transparency

Post 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.
User avatar
Amplify_Borba
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Layered Sprites With Transparency

Post 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.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
Post Reply