Page 1 of 1

Static Switches

PostPosted: Wed Oct 17, 2018 11:14 am
by mehran
Hi,
I am trying to get a better understanding of Shader-authoring, but as I am an artist it's kinda daunting, so I was hoping maybe I can get some answers directly from you guys.
For starters there are some concepts which I am trying to grasp.
1- Static switches
Can I use them to layer FX onto my objects? I am primarily trying to make a master Shader where I can just turn some a part of the shader-graph on and off. The documentation tells me that using the static switches will create a shader variant at compile time. Can someone explain to me if that is a good idea or not? and what are the pros-cons of such a workflow.
Like i said, I would ideally want a master shader which at it's core is a simple unlit shader and has further fx like matcaps, positional gradients, fake specs, baked AO,etc layered on top of it.

looking forward to your reply.
-best

Re: Static Switches

PostPosted: Wed Oct 17, 2018 1:37 pm
by Amplify_Borba
Hello, thank you for getting in touch and for your support!

The Static Switch node allows you to use Keywords in order to allow multiple shader variants without any performance hit, the main caveats being that these keywords are limited to 256 per project ( about 60 of those already being used internally by Unity ), and also the fact that using a high amount of Keywords will in turn create hundreds of variants, making the compile times shoot up.

Most of the times you are fine using those keywords because most projects don't have a high number of them and, in short, you may think of static switches as something reserved for complex operations or when dealing with specific platform requirements, for example, disabling soft particles in mobile.

I would also suggest checking out Unity's Multiple Shader Variants reference, which provides further information regarding this subject.

Please let me know if this helps and if you have any further questions, thanks!

Re: Static Switches

PostPosted: Thu Oct 18, 2018 10:39 am
by mehran
thank you for that detailed response.
Can you shed some light on using these static switches inside of mobile-android environment?

And can I ask some more questions regarding ASE here in this thread or should I open new threads per question.

Re: Static Switches

PostPosted: Thu Oct 18, 2018 11:04 am
by Amplify_Borba
No problem, we're here to help!

In short, creating more or less variants is independent of the target platform, so there are no special considerations regarding using Static Switches while targeting mobile, as the pros/cons are exactly the same as if your target was desktop, for example.

Regarding your other question, we'd prefer if you open a new one if the questions are too out of topic as it will help keep things organized for other users, just be sure to search our Unity Forum Thread as well as this Forum first to confirm if the question has already been asked, thanks!