Hello
I think I’ve raised this issue before but here goes.
How can I replicate what the built in Lit shader does in a custom shader graph? The issue is that the shadowmask produced during baking is not using the alpha cut values of the material/shader but rather the entire geometry. This doesn’t happen with the built in Lit shader. How can I reproduce that behavior in my custom shader graph?
Both shaders use alpha cut.
Built in shader produces correct shadow mask. My custom shader does not.
My custom shader (for demonstration purposes).
Is it a keyword I need to add or reference name I need to set?
This behavour persists in 2022+ but I’m working in 20211.3 atm.
Transparency in the lightmapper is unfortunately a bit magical, we have plans to improve it in the future, but for now, the implementation looks for a very specific setup. For your shader graph to support alpha cutout for lightmapping, 3 things must be the case:
- There must be a shader property named precisely
_Cutoff
(the property name, not the display name). This is the cutout alpha threshold the lightmapper will use. No other name will work.
- The texture containing the alpha to use (almost always the main albedo/color texture) must be marked as the main texture. In shader graph, this is done via the context menu on the texture property
- The render queue must be between “AlphaTest” and “Transparent”. IIRC shadergraph sets this for you automatically based on the rendering mode.
Hope this helps, lmk if you can’t get it working
Hi
Well, thank you! Those seems to have been the magic words. I wasn’t aware of the “Set as Main Texture” feature and it’s importance. I have been experimenting with the “_cutoff” parameter (when inspecting the Lit shader) but I guess it didn’t quite cut it (haha ).
I feel like this “quirk” should be a part of documentation (even though you might change it in the future).
Again, thanks for the help.