Animating a switch on and off

Node-based Shader Editor

Animating a switch on and off

Postby jzza » Sun Jan 27, 2019 3:53 pm

Hi

I have a switch in a shader which works when I use it in the inspector but if I try to animate it (using 0 for off and 1 for on) then it doesn't work, am I doing something wrong?
I'm using the Unity animator and keyframing the states.

Thanks
jzza
 
Posts: 3
Joined: Sun Jan 27, 2019 3:49 pm

Re: Animating a switch on and off

Postby jzza » Sun Jan 27, 2019 6:25 pm

I've got this working now, I've now used a toggle switch instead of a static switch and the toggle works fine when animated. Not sure why the static switch doesn't animate.
jzza
 
Posts: 3
Joined: Sun Jan 27, 2019 3:49 pm

Re: Animating a switch on and off

Postby Amplify_Borba » Tue Jan 29, 2019 9:17 am

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

In order to allow the shader to be changed in runtime through the Static Switch node, you likely need to set its Keyword Type property to Multi Compile, as it will generate all shader variants and include them all in the build. The Shader Feature type will only generate the used variants, and will only include in the build the active one, making it extremely efficient.

To clarify, the general purpose of the Static Switch node is to allow for the generation of a number of shader variants, which are generated internally by Unity depending on the type of Keyword that you're using.

In short, Toggles are comparable to Lerp nodes, as they execute all calculations, while Static Switches can execute only what you define.
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: Animating a switch on and off

Postby jzza » Tue Jan 29, 2019 2:18 pm

Thanks very much, I understand now.
jzza
 
Posts: 3
Joined: Sun Jan 27, 2019 3:49 pm

Re: Animating a switch on and off

Postby Amplify_Borba » Tue Jan 29, 2019 4:25 pm

Happy to help, please let us know if you come across any further questions, 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


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 9 guests