Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

2D point lights move in game view

Discussion in '2D Experimental Preview' started by runner409, Feb 2, 2021.

  1. runner409

    runner409

    Joined:
    Jan 27, 2017
    Posts:
    1
    When working in Unity 2019.4 the 2d lighting package worked as expected, but would cause terrible performance issues on mobile. I read a thread that said that this was improved with Unity 2021. So I tried it out, and it does indeed increase performance (from about 20fps to 60), but the point lights shift around as the camera moves. They don't match what the scene view shows. And the camera preview in scene mode shows what you would expect, only the game mode while running actually seems to be affected.
    You can see how the scene view is supposed to look:
    1.JPG
    and how it turns out in the game
    2.JPG
    If the camera moves up or down, the light will also shift it's position, usually in the opposite direction as the camera.
    An odd thing I noticed was that if I turn on Volumetric, it does appear in the correct place, while the light does not.
    3.JPG

    4.JPG
     
  2. nostawg

    nostawg

    Joined:
    Aug 23, 2015
    Posts:
    2
    I am seeing the same problem in a 2d Game - Light 2D component Spot light - moves as the camera follows the main character. Any thoughts anybody?
     
  3. nostawg

    nostawg

    Joined:
    Aug 23, 2015
    Posts:
    2
    I worked it out. For our project we had to tick on the Post-Processing checkbox on the Main Camera in the Rendering section of the Camera component inspector.

    This all happened after upgrading the project to 2021 as well, for context.
     
    Ryuuzakl, Taius and EricBeato like this.
  4. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    254
    I've looked into this, and I've made a fix. I'll try to get it merged when I'm able to.
     
    SudoCat, nostawg and NotaNaN like this.
  5. Taius

    Taius

    Joined:
    Dec 16, 2013
    Posts:
    4
    I had this same issue after upgrading from 2020.3.0f1 LTS to 2021.1.0f1.
    A few things changed:
    - Had to switch from using the 2D Pixel Perfect package camera component because it wasn't compatible with the UWRP - A warning was popping up in the Inspector. I was able to remove the 2D Pixel Perfect package and use the Pixel Perfect Camera (Experimental) from the UWRP package
    - The same issues that runner409 posted about, and some light blending settings seemed to be changed as well.

    Checking the Post Processing box on the MainCamera fixed the moving lights issue for me!
     
  6. RuneShiStorm

    RuneShiStorm

    Joined:
    Apr 28, 2017
    Posts:
    264
    Thank god!" Ive been looking for this forever! :D
     
  7. ThomasSoto

    ThomasSoto

    Joined:
    Aug 7, 2013
    Posts:
    26
    This is still not fixed on Unity LTS 2021.1.4f1
     
    Beacom likes this.
  8. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    254
    2021.1.4f1 shouldn't be an LTS version. Are you talking about 2020.3?
     
  9. RuneShiStorm

    RuneShiStorm

    Joined:
    Apr 28, 2017
    Posts:
    264
    Now my light are acting much worst then they did before. I reinstalled Unity and al lights got messed up again even if I clicked the Post-Processing checkbox...
    In game view they appear as really weird objects.
    Does this error message has anything to do with it?
     

    Attached Files:

  10. RickSaada1

    RickSaada1

    Joined:
    Mar 9, 2015
    Posts:
    16
    We're seeing this upgrading from 2021.1.13f1 to 2021.3.2f1 LTS. All our lights look fine in scene view, but in game view they're inverted and move opposite from the camera. So the light cones face down instead of up, and when panning (they're flashlights) they go the opposite direction.

    The Post Processing checkbox doesn't do anything for us.

    What build was this supposed to be fixed in?
     
  11. TomAE

    TomAE

    Joined:
    Apr 26, 2015
    Posts:
    2
    I tracked down the problem in our case: Unity changed how lighting UVs are calculated in the Sprite-Lit-Default shader.

    In 2021.1.13f1:

    Code (CSharp):
    1. o.lightingUV = ComputeNormalizedDeviceCoordinates(o.positionCS.xyz / o.positionCS.w);
    In 2021.3.2f1:

    Code (CSharp):
    1. o.lightingUV = half2(ComputeScreenPos(o.positionCS / o.positionCS.w).xy);
    So I made a copy of the shader and changed that one line back to the older version. Then I changed the material on our sprite renderers to use it, and the problem was gone.
     
    Skylaxx likes this.
  12. Skylaxx

    Skylaxx

    Joined:
    Jan 26, 2015
    Posts:
    1
    You save the day! thanks!