[2d Lights] We're using a perspective camera, any way to get 2D lights to work properly?

Hi,

We implemented 2D lights in 2020.3. They work great. Our game is topdown 2D, however we use a perspective camera to add some depth.

Since updating to 2021.1, the lights appear in a small area in the centre of the screen, bleeding out to the edge. As soon as I change back to a orthographic camera they work correctly, but lose the lovely depth we’ve been working on.

Obviously, we could stop using the 2D renderer and implement normal lights, but we’ve put in so much work already and 2D lights have been giving us the desired effect. They look awesome (in 2020.3 at least!).

Thanks,

(I think I posted this in the wrong form before, sorry)

I have the same problem… I hope someone found a solution… :slight_smile:

Fingers crossed this is a bug that will be fixed rather than a feature ie you have to use a orthographic camera :smile:

As far as I know, 2D lights where never meant or designed to work with perspective cameras. ( @Chris_Chu correct me if I am wrong). :sunglasses:
Unfortunately you will likely need to go with option B (use 3D lights). :frowning:

[EDIT] Yep. I stand corrected. Hopefully the 2D lights get patched!

Ugh, that’s a real pain. The 2D lights do everything we need. 3D lights and sprites (that rhymes ) are such a hassle.

As it currently works with a perspective camera in 2020.2.5f, I’m hoping there might be a “fix”.

If anyone from the team could comment, that would be amazing as I need to plan.

Thanks!

3 Likes

That’s hilarious as one of Unity’s own videos from Unite 2020 heavily featuring the 2D lights system, Tails of Iron, is using a perspective camera with 2D lights!

I hope this is not the case, as the way they are working in 2020.3 is great.

I have the same problem. My lights don’t work anymore since I upgraded and setting the camera to orthographic fixes it. But as others have said, I want to use a perspective camera. This worked before and is also in multiple official tutorials. This needs to be fixed. You can’t expect everyone to use an orthographic camera for 2D games.

Hopefully it’ll get fixed soon!

1 Like

Let me start by saying, lighting with perspective is supposed to work.

There were a number of bugs that cropped up from changes made to the SRP core and Universal, that changed the behavior for our perspective lights. I thought I fixed most of the issues in 2021.1f1. Did either of you tried 2021.1f1? If so can you log a bug so I can look into fixing this?

5 Likes

Thanks so much for the reply. I’ll download that version and have a test.

I just tried 2021.1f3 and my lights seem to be working again. Thank you!

2 Likes

Glad to hear it.

1 Like

Hello.

We’ve just updated to Unity 2021.1.5f1 and 2D lights does work. However, ShadowCaster2D seems to be still limited to Orthographic camera. The Shadow texture is all wrong when using a Perspective camera. Is it possible to get a fix for this since we are using the ShadowCaster2D in our game?

Thanks,
Francis

Sorry I missed this when I made my fix. There is a fix for this incoming and I’ll be looking at adding more test coverage so that this hopefully won’t happen in the future.

Great! We’ll be waiting for the fix. Thank you for this nice feature.

@Chris_Chu I updated Unity to 2021.1.5f1 and can confirm that 2D lights work now!

However I have a new issue I can not explain.
Please see the image attached.

Basically: lights are mirrored by Y axis.
So in the editor I setup light at Y = -6 and in game view it turns in Y=6.

I made an image with examples. Second light is in Y=0 and it matches in both game view and editor.
Same behavior for both orthographic & perspective cameras.

UPDATE: the light position is correct in camera preview (smaill window in editor window when camera is selected).

UPDATE #2: Enabling Post-Processing on camera fixed the issue, but that is weird.

Hello. Any ETA when this fix will be released? We are getting really close to finish our Vertical Slice and we want to send it to some publishers. However, we cannot send the build until this is fixed since it breaks a gameplay feature in our game.

Worst case, is this something that I can fix on my side. Is this exposed in the package code?

Thanks

I’ll check on this and get back to you.

One option you could try in the meantime is that you could get this branch from our graphics repo

This is what will go out in the next version of URP and should have any fixes in it.

1 Like

Hello Chris, I just downloaded the latest 2021.1 staging repo and manually added com.unity.render-pipelines.universal to our project. It seems like the issue with ShadowCaster2D is still there. Has the fix been pushed in 2021.1? I can’t see anything related to this issue in the com.unity.render-pipelines.universal history. This bug is really problematic for us right now as it breaks the whole gameplay design of our level.

Just to add to this thread, the perspective issue I started this thread with, regarding 2D lights has been fixed, however the same issue still persists with ShadowCaster2D.

Could we get an update from the unity team on this?

Thanks :slight_smile:

3 Likes