#(Shader Graph) Custom lighting advice

1 messages · Page 1 of 1 (latest)

dreamy grove
#

Hello,
I'm making a custom lighting shader using shader graph and I was wondering if it was a good idea to set the multi-compile keywords in a custom function rather than in the shader graph interface, like in this image for example ?

It works well and in the inspector I see that it greatly reduces the number of variants, but I don't know if it really reduces the number of shader variants in the end.

sturdy sigil
#

The pragma should have an extra _ inbetween multi_compile and the other keyword(s) to generate both "on" and "off" variants. Currently the shader might only work correctly in some cases (i.e. only in Forward+ path due to first keyword). Cookies one might still look fine without a cookie assigned, but would still be sampling a plain texture.

With that, it shouldn't be any different afaik. Though shadergraph limits the number of keyword nodes (without adjusting settings/preferences), while I think using pragmas can avoid that

dreamy grove
#

Ah ok, that's why it reduced the number of variants so much. I understand better now.

Does this also allow me to do variant stripping, for example if I define a keyword inside an #if _OTHERKEYWORD Does this generate fewer variants ? If so, does Shader Graph do this automatically too ?

sturdy sigil
dreamy grove
#

Okay, thanks for the advice Cyan.
Since there's still a lot I don't know about custom lighting, I'll keep posting here if I have any questions.

By the way, do you know how to access the Decal buffer in Shader Graph, or if it's even possible ?