Help with 'reveal' shader

Node-based Shader Editor

Help with 'reveal' shader

Postby mephistonight » Mon Mar 25, 2019 9:15 pm

Hi folks,

I'm trying to figure out how to achieve an effect and I'm hoping someone can give me some pointers.

Let's say I have a sprite on the UI that is a horizontal black line (image). I want its alpha to be 0 to start with so it's completely transparent and then over time, set it to reveal the line from left to right, as if the line is being drawn on screen. I thought it would be simple but I'm struggling: I had a look at alpha masks and how to do that but I don't think that's going to help me? Is there a way to set the alpha of an image / sprite on a per pixel basis, or some other method I'm not aware of that will achieve what I'm looking for?

Many thanks for any pointers you can offer.

Regards,
M
mephistonight
 
Posts: 2
Joined: Sat May 19, 2018 9:31 am

Re: Help with 'reveal' shader

Postby Amplify_Borba » Tue Mar 26, 2019 9:26 am

Hello, thank you for getting in touch and for your support!

Here's a simple sample to help you get started, using our Sprite Shader Template:

SpriteAlphaTransitionShader.zip

Image

In here we use the Lerp node that interpolates between the sprite's full Alpha value and 0, then pass that data to the Alpha channel of the of the final RGBA data that is passed to the output node through the Append node, so that it gets a value between the full alpha and 0, which makes it fully transparent.

We calculate the interpolator as a gradient through the Texture's U coordinates, and adjust its position and softness through two float properties, so that they might be adjusted via C# script in order to control the transition.

Feel free to check our the Smear and ForceShield samples for two examples on how to use scripting to pass values into an ASE shader.

Please let us 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!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Help with 'reveal' shader

Postby mephistonight » Tue Mar 26, 2019 4:52 pm

Thank you very much for your response, that's incredibly good of you to provide and explain the shader to achieve exactly what I wanted. I see now that it was the UV offset and the lerp and sqwizzle nodes I wasn't understanding.

This is the second time I've contacted Amplify and I have to say, huge thumbs up for going above and beyond what's expected on the customer support. It's been great both times.

Many thanks,
M
mephistonight
 
Posts: 2
Joined: Sat May 19, 2018 9:31 am

Re: Help with 'reveal' shader

Postby Amplify_Borba » Tue Mar 26, 2019 5:39 pm

Glad I could be of assistance, we do our best to help whenever we can!

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 and your feedback is extremely valuable to us.

Don't hesitate to let us know if you have any further questions, and thank you for the kind words.
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!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: Google [Bot] and 10 guests