When I build bundles using the Addressables system, and go into Play Mode using the packed bundles, materials that use the Spine-Skeleton-URP (Universal Render Pipeline/Spine/Skeleton) do not work.

This happens both for when I instantiate SkeletonAnimation Prefabs from AssetReference, or when I load SkeletonDataAsset and put it into a SkeletonAnimation prefab and re-initialize the skeleton.

The resulting mesh shows up invisible but I can see the gizmo bones.

The aforementioned material, prefab, and shader are all packed into the same bundle. I tested it on a single scene, with only those assets packed, and the issue still persists.

The strange thing is that this only happens in an existing project, and I can't seem to find the exact root cause that's unique to that project. I created a brand new project, added URP, Spine, Addressables, all with the same settings, and built the bundles in the same exact way, and cannot replicate the issue.

The issue won't occur if I enable GPU instancing on the material. Or, the catch-all is that I set Instancing Variants to Keep All (from Strip Unused) in Graphics Settings. This at least shows me that this specific shader is getting stripped (though it appears in the bundle), but that is not the case for newly created projects, and I don't understand why...

Anyone have any idea on a particular setting that I may have missed?

Update 1:
Ah figured it out. Will post my findings later. :)

Update 2:
So here's the root cause based on my findings:

When using URP and the Lighting -> Additional Lights -> Cast Shadows feature is enabled in the active URP asset, all Forward Pass variants of the Universal Render Pipeline/Spine/Skeleton shader get stripped out as "invalid variants" by this snippet in the URP/Editor/ShaderPreprocessor.cs:
bool StripInvalidVariants(ShaderCompilerData compilerData)
bool isMainShadowNoCascades = compilerData.shaderKeywordSet.IsEnabled(m_MainLightShadows);
bool isMainShadowCascades = compilerData.shaderKeywordSet.IsEnabled(m_MainLightShadowsCascades);
bool isMainShadowScreen = compilerData.shaderKeywordSet.IsEnabled(m_MainLightShadowsScreen);
bool isMainShadow = isMainShadowNoCascades || isMainShadowCascades || isMainShadowScreen;

bool isAdditionalShadow = compilerData.shaderKeywordSet.IsEnabled(m_AdditionalLightShadows);
if (isAdditionalShadow && !(compilerData.shaderKeywordSet.IsEnabled(m_AdditionalLightsPixel) || compilerData.shaderKeywordSet.IsEnabled(m_ClusteredRendering) || compilerData.shaderKeywordSet.IsEnabled(m_DeferredStencil)))
return true; // <--- STRIP HERE.

bool isShadowVariant = isMainShadow || isAdditionalShadow;
if (!isShadowVariant && compilerData.shaderKeywordSet.IsEnabled(m_SoftShadows))
return true;

return false;
The rest gets stripped out for having unused features (in my case).

The Spine-Skeleton-URP.shader Forward Pass uses the following URP keywords:
// -------------------------------------
// Universal Pipeline keywords
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile _ _SHADOWS_SOFT
Because of the way the condition is structured, when the _ADDITIONAL_LIGHT_SHADOWS feature is enabled, the variants get considered, but ultimately stripped as invalid for not having any of the other three keywords. When _ADDITIONAL_LIGHT_SHADOWS feature is disabled, some variants of the shader get to skip this step, and successfully end up in the asset bundle build.

I'm not sure if this is by design on the part of the Spine-Skeleton-URP shader, but getting the shader stripped out when URP features are added (rather than removed) did make the issue difficult to trace.
You do not have the required permissions to view the files attached to this post.
  • Posts: 6


Sorry for the troubles! Thanks very much for reporting and for digging deeper and discovering the cause of the problem!

Strangely for some reason when trying to reproduce the issue following your description, it was always working without the shader variant being stripped (also in a built executable). Nevertheless the lighting and shadow related #pragma multi_compile statements in the unlit shader are unnecessary and shall be removed anyway.

We have just pushed a bugfix on the 4.1 and 4.2-beta branches and released new Spine URP shaders packages on the download page:
spine-unity Download
Please let us know if the new package resolves the issue for you.

Issue ticket URL for later reference:
User avatar

  • Posts: 4328


Thank you, Harald! It took me a while to replicate the issue consistently too as I realized late that I had to do a Clean Build Cache of addressables whenever I changed a feature in the URP asset.

I started with the default URP asset generated through Create > Rendering > URP Asset (with Universal Renderer), and just ticked that feature on. I'm able to replicate it both on Unity 2021.3 and 2022.1, and the highest Addressable package version that are compatible with each.

With the same setup and steps, the issue is resolved with the latest 4.1.5 Spine URP shaders package. :)
  • Posts: 6


Thanks for the writeup and for confirming that it works now, very glad to hear! :)
User avatar

  • Posts: 4328

Return to Unity