I was experiencing some slow frame render times when using the 2D renderer with lights, and noticed that in some scenes I was seeing almost double the amount of draw calls because of the the normal map pass for 2D lights.
I would like to prevent this normal map pass from rendering, as I am only using global 2D lights, and no normal maps/secondary textures are assigned to sprites.
I noticed that if a SpriteMask is used in the scene, then the normal map pass will always render even if there are no normal maps present, or lights with normal map rendering enabled. This is happening on line 224 of .../Runtime/2D/Passes/Render2DLightingPass.cs which reads:
if (layerBatch.lightStats.totalNormalMapUsage > 0 ||
(hasSpriteMask && i == 0) ||
(hasSpriteMask && i + 1 == batchCount))
notice the use of hasSpriteMask which is a cached value from line 197:
// Account for Sprite Mask and normal map usage where the first and last layer has to render the stencil pass
bool hasSpriteMask = UnityEngine.SpriteMaskUtility.HasSpriteMaskInScene();
If I manually modify Render2DLightingPass and force the normal pass to not render, my project visually looks exactly the same.
Is there a way to use SpriteMasks, but still avoid rendering this normal map pass? Is there a specific reason why SpriteMasks force the normal pass to render?
Any insight is much appreciated. Thank you!