Hi,
I am facing a weird issue with 2D lights. Lights are not correctly applied. And another issue is: even if I dont apply light to a layer, all layers are still lit.
Please, see below screenshots. Its a sample scene with only 3 sprites each in different sorting layers in sequence (Background, Middleground, Default). Scene has only one Global Light. When I set target sorting layers to none, light gets applied to all layers. Only when I disable the light from inspector all sprites turn black. Ideally, none target sorting layers should also turn my scene black. Another issue is: when I set specific layer, it doesnt apply to that particular layer. This is just an example of Global Light. Point and Parametric light behaves the same way.
I have also put all sprites in different z position to be sure.
URP Version: 8.2.0
Unity Version: 2020.1.2f1
Material Used for all sprites: Universal Render Pipeline/2d/Sprite-Lit-Default
Any help would be appreciated.
Are you sure you’re using the URP/2d/Sprite shader on all of the actual sprite objects?
Within your sprite renderer are you setting the sorting layer there? The Layer up at the top of the editor isn’t what you’re targeting with the light.
Is there a reason you’re using 2020 instead of 2019.4? Unless there is a specific feature you need in 2020 I’d recommend using a LTS version of 2019.4.
Update:
I tried with different URP versions and looks like this works fine till 7.3.1. Post 7.3.1 all versions have this issue.
Do anyone else has similar issue? I have reverted URP version to 7.3.1 for now.
Thanks for reply. I am certain that I am using correct sorting layers. Not layers. Please, see below screenshot of background layer sprite. That screenshot also shows the material and shader.
While playing around this, I also found that if I add another Parametric light just sake of keeping it. Everything started working. So, it’s not like URP and lighting are not working at all.
I am not looking for any specific feature in 2020. But, since I just started out project and 2020 will likely be LTS by next year spring, I thought let’s start with latest. I think my project will go beyond 2021 December for sure.
Before I hit this snag, I didnt have any issues. Moreover, I am not using any major preview version packages to be on safer side. But, I will certainly keep your suggestion in mind and decided sooner.
[170429-spritescreenshot.jpg|170429]
Think I got a solution. What I did is to keep the light with the target sorting layer, add a global light, set the new global lights color too black, and change target sorting layer of the new global light to all. Hope it works for all of you.
Here is the best answer and updated.
Follow the link
Set the “Target Sorting Layers” to “All” on the light script on the light object, for the light to effect every single object.