Hello Everyone!

I have a project in which everything takes place in a 3D scene. All the 3D objects cast shadows, and so does my Spine character—but the character doesn’t receive shadows. The project is set up in Unity using URP, and the only material that works (everything else shows Unity’s dramatic magenta “missing shader” color) is Spine/Skeleton. If I switch the character to the URP Lit material, its 2-D animated shadow stops being cast altogether (I’ve attached this gif screenshot to illustrate).

What I’d really love is for the Spine character to receive shadows from those 3D objects (or from sprites that cast them). Is that possible with a particular material or Unity setting?

Thanks in advance!

Related Discussions
...

To have your Spine character receive shadows in a 3D environment using Unity's URP, you should ensure that you are using the correct Spine URP shaders. The Spine URP Shaders UPM package provides shaders that are compatible with URP and should be used for your Spine character to properly interact with lighting and shadows in a 3D scene. You can find more information and download the package from the [Spine Unity documentation](https://esotericsoftware.com/spine-unity#URP-Shaders

I'm testing all URP UPM shaders but no one works for me, am I doing something wrong or missing something?

After keeping my test I found out that "Skeleton Lit" from the URP shaders is in the section "failed to compile" with this error:

Shader error in 'Universal Render Pipeline/Spine/Skeleton Lit': undeclared identifier 'GetMeshRenderingLightLayer' at /LostBook/Library/PackageCache/com.esotericsoftware.spine.urp-shaders@954ead4ca6c9/Shaders/Include/Spine-Common-URP.hlsl(45) (on d3d11)

Compiling Subshader: 0, Pass: ForwardLit, Fragment program with _ADAPTIVE_PROBE_VOLUMES_PER_PIXEL _ADDITIONAL_LIGHTS _ADDITIONAL_LIGHT_SHADOWS _LIGHT_LAYERS _MAIN_LIGHT_SHADOWS_CASCADE _RECEIVE_SHADOWS_OFF _SHADOWS_SOFT
Platform defines: SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_RGBM_ENCODING UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF1 UNITY_PLATFORM_SUPPORTS_DEPTH_FETCH UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
Disabled keywords: FOG_EXP FOG_EXP2 FOG_LINEAR INSTANCING_ON PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_FULL_HDR UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING _ADDITIONAL_LIGHTS_VERTEX _DOUBLE_SIDED_LIGHTING _FORWARD_PLUS _LIGHT_AFFECTS_ADDITIVE _LIGHT_COOKIES _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_SCREEN _MIXED_LIGHTING_SUBTRACTIVE _RECEIVE_SHADOWS _STRAIGHT_ALPHA_INPUT _TINT_BLACK_ON _WRITE_RENDERING_LAYERS

For your information, I'm using Unity 6000.1.4f1, Spine-Unity Runtime 4.2.106, Spine-csharp 4.3.2 and Spine URP 4.2.43

I hope this helps you helping me!

Please note that the spine-unity and Spine URP Shaders UPM package are officially compatible with Unity 6000.0 but not with 6000.1 (yet):
https://esotericsoftware.com/spine-unity-download#Download

Nevertheless, thanks for reporting, we will happily fix the respective compile errors and add the respective automatic branching to the affected shaders so that it is compatible again.

  • Yimec님이 이에 답장했습니다.

    Harald Thank you for your response @Harald

    Any idea or roadmap to know when this will be compatible?

    Thank you!

    @Yimec Unfortunately I could neither reproduce your observed behaviour with Unity 6000.1.5f1 nor with the latest 6000.1.9f1, everything compiled without issues on our end. Thus I assume it's related to your project and render settings, affecting the defines used while compiling the shaders.

    Could you please send us a minimal Unity project which still shows this issue? You can send it as a zip file to contact@esotericsoftware.com, briefly mentioning this forum thread URL so that we know the context. Then we should be able to reproduce the issue on our end more easily as well.

    Hello @Harald! Thank you for your follow up.

    I've checked the problem and the issue seems to be related to URP 17.1.0 (which I'm using).

    With ChatGPT's help I found out that changin this part in the Spine-Common-URP.hlsl:

    uint GetMeshRenderingLayerBackwardsCompatible()
    {
        #if IS_URP_14_OR_NEWER
        return GetMeshRenderingLayer();
        #elif IS_URP_12_OR_NEWER
        return GetMeshRenderingLightLayer();
        #else
        return 0;
        #endif
    }

    with

    uint GetMeshRenderingLayerBackwardsCompatible()
    {
        #if IS_URP_14_OR_NEWER
            // Compatible con URP 14+ incluyendo URP 17
            return GetMeshRenderingLayer();
        #else
            // Para URP 12 y anteriores, GetMeshRenderingLightLayer ya no se usa
            return 0;
        #endif
    }

    as long as URP 17.1.0 no longer uses GetMeshRenderingLightLayer().

    I don't know if this is a workaround or is an useful fix, but now I can get my character receive shadows! (Until next package update, which will overwrite my changes haha)

    • Harald님이 이에 답장했습니다.

      Yimec I've checked the problem and the issue seems to be related to URP 17.1.0 (which I'm using).

      Thanks for the follow up. No, this is not the problem, our projects are also using URP package version 17.1.0. The problem is most likely as I've described above:
      "Thus I assume it's related to your project and render settings, affecting the defines used while compiling the shaders."

      Yimec With ChatGPT's help I found out that changin this part in the Spine-Common-URP.hlsl:
      ..
      as long as URP 17.1.0 no longer uses GetMeshRenderingLightLayer().
      I don't know if this is a workaround or is an useful fix, but now I can get my character receive shadows!

      The proposed changes by ChatGPT make little sense as a proper fix if you read the code:

      #if IS_URP_14_OR_NEWER
          return GetMeshRenderingLayer(); // this path should be taken when URP 17.1.0 is present
      #elif IS_URP_12_OR_NEWER
          return GetMeshRenderingLightLayer(); // chatGPT removed this branch, which should be used only on  URP versions 12 and 13.

      So what shall be fixed is that IS_URP_14_OR_NEWER needs to be set to true in our shaders in your configuration, which for some reason is not the case. I'll perform some checks on our end and will get back to you soon.

      So what shall be fixed is that IS_URP_14_OR_NEWER needs to be set to true in our shaders in your configuration, which for some reason is not the case. I'll perform some checks on our end and will get back to you soon.

      I've just confirmed that the IS_URP_14_OR_NEWER define is also not set in our project, so while we can't reproduce your exact error, we can reproduce the incorrect definition which leads to yours. I will get back to you as soon as I have a bugfix ready. Thanks for reporting!

      @Yimec We've just released a bugfix for this issue.
      Details: The URP version define IS_URP_14_OR_NEWER should now again be recognized and set correctly after Unity has changed a define on their end.

      A new Spine URP Shaders UPM 4.2 package is available for download:
      https://esotericsoftware.com/spine-unity-download
      Please let us know if this resolves the issue on your end as well. Thanks again for reporting!

      Issue ticket URL for later reference:
      EsotericSoftware/spine-runtimes2878

      Hello @Harald,
      it works perfectly!

      Thank you for your quick update and follow up!!

      • Harald님이 이에 답장했습니다.
      • Harald 님이 이 게시물을 좋아합니다..

        Yimec Very glad to hear, thanks for checking!