Shader variants

Node-based Shader Editor

Shader variants

Postby wintomee » Wed Oct 10, 2018 3:26 pm

Hi.
I made a nice little custom lit sprite shader with quite a few options.
The default one is standard transparent and I created a duplicate for blending variants where I can customize types of Alpha Blend.

Now, I'd like to somehow merge these two, so that when I update the default shader, it reflects into the other shader.
The only way I can think of now is making the shader a function included in the other shader, but it feels more like a hack than a real solution.

I tried to find more about usage of subshaders in Amplify, but failed to find anything.
Is there a nice and clean solution?

Thanks
wintomee
 
Posts: 9
Joined: Wed Oct 10, 2018 3:17 pm

Re: Shader variants

Postby Amplify_Borba » Wed Oct 10, 2018 4:08 pm

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

In this situation, you'll have to merge both variants into a single shader, and make use of Keywords through our Static Switch node in order to the generate of a number of Shader Variants, which are generated internally by Unity depending on the type of Keyword that you're using.

If you don't need to change the variant in runtime, set the Keyword Type to Shader Feature, as this way Unity will only generate the used variants and will only include in the build the active one, while in Multi Compile it generates all the variants and includes them all in the build,

Also, be mindful that the use of Keywords is limited to 256 in Unity, and about 60 are already being used internally.

Regarding having shared code between variants, using Shader Functions is the way to go.

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


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 0 guests