[URP] Fix Solid Baked Shadows on Transparent Custom Shaders
Solution
Unity 2021.x - Unity 6.3.x
Published 28 days ago
Lightmapping in Unity often fails to recognize alpha clipping in custom shaders, resulting in solid rectangular shadows. This occurs because the Progressive Lightmapper specifically samples a property named _MainTex to determine transparency, ignoring custom shader logic or alternative property names like _BaseMap.
The Unity lightmapper requires the property name _MainTex to evaluate alpha for baked shadows. If your shader uses a different property name, the baker defaults to opaque behavior.
- Map your transparency mask to the alpha channel of your primary texture.
- In your shader code or
Shader Graph, ensure the primary texture property reference is named exactly _MainTex. - Assign this texture to the Base Map slot on the
Materialinspector. - Enable Alpha Clipping on the
Materialand adjust the threshold. - Re-bake your lighting using the
Lightingwindow.
Additional Tips
- The _MainTex naming convention is a legacy requirement for the
Progressive LightmapperandEnlightensystems. - Ensure the texture import settings have Alpha Source set to
Input Texture Alphato be correctly read by the baker. - If using
Shader Graph, check the Override Property Declaration in the Graph Inspector to ensure the internal reference is exactly _MainTex.
TL;DR
Shadow clipping issues in baked lighting are resolved by mapping the transparency mask to the _MainTex property, which the lightmapper uses for alpha evaluation.
Related Posts Haven't quite found a solution to your problem? We think these posts might help you.
Content inspired by a Unity discussion post.