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

Question Shader graph's custom shader does not update object's shadow unless variable is changed from inspctr

Discussion in 'Universal Render Pipeline' started by DenGrvubra, Apr 20, 2022.

  1. DenGrvubra

    DenGrvubra

    Joined:
    Apr 11, 2022
    Posts:
    2
    Hello, I have a shader that fades the object away when it is close to the camera. It almost works, but the problem is that objects shadow does not update when object's transparency changes.
    I'm using screen position node to get the distance to the camera, if I change it to vector4 variable and tweak it's W value from the inspector not only the fading will work as expected, but also the shadow will adjust accordingly. If I use screen position node and move the camera then the object will fade correctly, but it's shadow will not update.

    Here the shadow is correct and updates upon updating Vector4 TEST from the inspector.
    https://imgur.com/a/PhVGPA1
    https://imgur.com/a/3sdQmGP

    And here is how the shader should look like:
    https://imgur.com/a/sp9hHvL

    And then the shadow does not change. It stays on the initial value (and even that value is not correct).
    https://imgur.com/a/T8BAzV9

    Hopefully I was able to get my message across and posted my question correctly.
     
    Last edited: Apr 20, 2022
  2. DenGrvubra

    DenGrvubra

    Joined:
    Apr 11, 2022
    Posts:
    2
    Using the distance node with camera position and position nodes plugged in instead does the trick, but I still don't understand, why screen position node doesn't. Also which one of those method is more efficient..