Sorry to hear that!
While we didn't experience this ourselves yet, this has been reported once here on this forum thread:
Compiling URP Shader Variants Takes Hours
Since I need to fix a Unity 2021.2 related URP shaders issue, I will have a look at the shader variants and whether these could be reduced.
IndieDoroid wroteI read on the Unity forum that we should remove any shaders that we don't need. For the Spine shaders, what are the bets practices for shader removal? Are they interconnected in some ways?
While the URP .shader
files are not interconnected (only shaders that have UsePass <other/shader/pass>
in it need the other file), this will not help you much.
The best optimization for your case would be to open the Spine-Sprite-URP.shader
file and reduce some variants by removing complete lines, or single keyword options. While #pragma shader_feature
statements should only be compile when they are actually used, it would be worth a try removing or reducing those lines starting here:
https://github.com/EsotericSoftware/spine-runtimes/blob/4.0/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Sprite-URP.shader#L84
E.g. if you use the URP/Spine/Sprite
shader and never use any of the Additive
or Multiply
shader Blend modes , you can reduce the line from:
#pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAPREMULTIPLY_VERTEX_ONLY _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
to this:
#pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAPREMULTIPLY_VERTEX_ONLY
Also you can remove the following lines if you don't use a diffuse ramp for lighting:
https://github.com/EsotericSoftware/spine-runtimes/blob/4.0/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Sprite-URP.shader#L90-L91
If this reduces the compile time and the number of compiled variants (from 39936 in your case above), you're on a good track. Note that a single binary shader_feature
will double the number of variants, so it quickly sums up.