Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. 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

    wechat_os_Qy0yKnjoAKnCVgn7Y-kwnUX2o

    Joined:
    Dec 13, 2019
    Posts:
    6
    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.
    PlayAnimationInEditor_PlayMode.gif
    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.
    PlayAnimationInEditor.gif

    Here is my ShaderGraph for the material I am using for this quad.
    upload_2021-1-23_21-27-59.png

    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.

    MoveOutofSpotlight.gif

    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

    wechat_os_Qy0yKnjoAKnCVgn7Y-kwnUX2o

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