Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved URP casting the wrong shadow

Discussion in 'General Graphics' started by wechat_os_Qy0yKnjoAKnCVgn7Y-kwnUX2o, Jan 23, 2021.

  1. wechat_os_Qy0yKnjoAKnCVgn7Y-kwnUX2o


    Dec 13, 2019
    Hi everyone,

    I am using Unity 2020.1.13f1c1 and I am currently experiencing some shadow casting problems where the wrong shadow is cast.
    When I enter play mode in Editor, this happens.
    The shadow of the character body becomes the shadow of the head for the first key frame in my animation.
    But it does not happen in Editor when I play the animation without entering play mode. The shadow is normal there.

    Here is my ShaderGraph for the material I am using for this quad.

    Could anyone help me with this? Is there anywhere I could have done wrong? Or is this a glitch in Unity?

    [Also posted on StackOverflow]

    --------------------UPDATE 25/01/2021--------------------

    Forgot to mention that the body and the head are 2 seperate GameObjects which both use the ShaderGraph I posted above.
    And I upgraded this project from an older version of Unity (2019.3.4f1).

    Also, I notice that if I move the head out of the range of the Spotlight, the shadow is normal again.


    Any thoughts maybe?

    --------------------UPDATE 26/01/2021--------------------

    FrameDebug reveals something strange. The rendering pipeline is actually using 2 different textures for shadow and opaque rendering. In shadow rendering pass, it uses the texture for the head. But in opaque rendering pass, it uses the texture from the body.

    I am not very familiar with the insides of URP rendering pipeline, but how is it possible for the pipeline to switch the texture for the same mesh between shadow rendering pass and opaque rendering pass?
    Last edited: Jan 26, 2021
  2. wechat_os_Qy0yKnjoAKnCVgn7Y-kwnUX2o


    Dec 13, 2019
    Nvm it seems to be a Unity project auto-upgrade problem. Redoing animation solves it.