Search Unity

Question Weird lighting on game view and builds when upgrading my URP project from 2020.3.32 to 2021.3.1

Discussion in 'General Graphics' started by RoyBarina, May 4, 2022.

  1. RoyBarina

    RoyBarina

    Joined:
    Jul 3, 2017
    Posts:
    98
    Hello
    Since 2021.3 became the latest LTS, I thought I'll give it a shot. This isn't the first time I tried upgrading my project to 2021.x, every time I do, I get a lot of issues that forces me to checkout back to 2020.3.

    I did follow this post that didn't really helped basically..
    My issue, this time (inter alia), regarding graphics as can be observed in this footage:
    https://drive.google.com/file/d/1DH7r_vughJaFcVI7AasiBZijraJusm4T/view?usp=sharing

    Game view behaves very different from scene view and produces wrong lightings\shadows.. it's like it revolving around world origin.. this is also the behavior in builds. scene view works great though.

    All of the objects in this project uses a mesh deformation in form of a "world curvature" that just pushes vertices that are far from the camera down a bit. I exaggerated that in the footage to make the issue be more pronounced..

    I thought maybe because in 2021 Unity won't calculate vertex normals for us anymore (so I heard..) so I did updated my shaders to support this.. while it did makes the lighting looks correct, it didn't fix that weird lighting glitches...
     
    Last edited: May 4, 2022
  2. RoyBarina

    RoyBarina

    Joined:
    Jul 3, 2017
    Posts:
    98
    Something's wrong with Shader Graph's camera node.
    The issue occurs only when I use the "Position" attribute in the Camera node.
    When I change to a custom position and pass the transform.position of the camera object, the issue is gone.

    I tested it like so:
    Screenshot 2022-05-05 032100.png
    Code (CSharp):
    1. #if UNITY_EDITOR
    2.     private void Update()
    3.     {
    4.         if (material)
    5.             material.SetVector("_Pos", transform.position);
    6.     }
    7. #endif
    "Pos" is my custom position set within the Update method of a script attached to my main camera, so 'transform.position' and 'position' attribute in camera node are the same. right?
    But when I toggle 'Custom Position" it behave differently.. no issue when its 'on'.
    What am I missing? on 2020.x and in the scene view it works without issues.
     
  3. RoyBarina

    RoyBarina

    Joined:
    Jul 3, 2017
    Posts:
    98