CanvasGroup alpha

Node-based Shader Editor

CanvasGroup alpha

Postby ShawnFeatherly » Wed Aug 22, 2018 2:01 am

I'm struggling figuring out the right output node settings to make a shader that is affected by the uGUI CanvasGroup components Alpha value.

If I setup a scene with a uGUI Canvas that has a CanvasGroup component and has a child gameobject with an Image component on it I can change its material to "Sprites-Default" or "Default-Particle". Afterwards I can modify the alpha on the parent objects CanvasGroup component and see a transparency effect.

I tried downloading the official Unity sample shaders and examining "Particle Alpha Blend.shader". In the Amplify Shader Editor I tried changing the sub-shader's Blend Mode for alpha to "Alpha Blend", but it doesn't have the same result as the default shaders. I'm guessing it's because the Unity shader has a "Category" section defining the Blend rather than in the SubShader?

Is there any way I can recreate the CanvasGroup alpha blend that works in the default Unity shaders with the Amplify Shader editor?
ShawnFeatherly
 
Posts: 2
Joined: Wed Aug 22, 2018 1:53 am

Re: CanvasGroup alpha

Postby Amplify_Borba » Wed Aug 22, 2018 10:26 am

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

In order to access the alpha for the UI elements, you'll need to use our UI Template by selecting it in the shader type:

Image

Make sure its Blend Mode is set to Alpha Blend in the Output Node's parameters, similar to the image above.

The Vertex Color node gives you access to both the tint ( rgb ) and alpha ( a ) data from the UI elements. Using our SimpleUI sample as the base for the example below, you would have to multiply the alpha with a float property, and then combine it with the rgb data through the append node:

Image

This will allow you to control the alpha for all the elements using the float slider.

Please let me know if this helps, thanks!
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: CanvasGroup alpha

Postby ShawnFeatherly » Wed Aug 22, 2018 6:26 pm

That did it perfectly!

Many thanks for the detailed explanation and the pictures. I would of never thought to try the Vertex Color node.

Just out of curiosity, does the Vertex Color node working correctly have to do with the Shader Type being set as "Legacy/Default UI"?
ShawnFeatherly
 
Posts: 2
Joined: Wed Aug 22, 2018 1:53 am

Re: CanvasGroup alpha

Postby Amplify_Borba » Thu Aug 23, 2018 9:21 am

No problem, glad that I was able to help!

The Vertex Color node works in the same way, no matter the chosen shader type.

Please let me know if you have any further 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!
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: No registered users and 31 guests

cron