2D point lights move in game view

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:
6793754--787373--1.JPG
and how it turns out in the game
6793754--787376--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.
6793754--787379--3.JPG

6793754--787382--4.JPG

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?

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.

3 Likes

I’ve looked into this, and I’ve made a fix. I’ll try to get it merged when I’m able to.

3 Likes

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!

Thank god!" Ive been looking for this forever! :smile:

This is still not fixed on Unity LTS 2021.1.4f1

1 Like

2021.1.4f1 shouldn’t be an LTS version. Are you talking about 2020.3?

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?

7461253--916006--shader.png

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?

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:

o.lightingUV = ComputeNormalizedDeviceCoordinates(o.positionCS.xyz / o.positionCS.w);

In 2021.3.2f1:

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.

1 Like

You save the day! thanks!