unity – Lights do not fully respect SortingLayers in Universal Render Pipeline

I just installed Universal Render Pipeline into my 2D project and believe I have everything configured correctly.

  • I created a new RenderPipeline asset
  • I deleted the default Renderer on it and added a new 2D Renderer
  • I added the RenderPipeline into the Graphics section of my Project Settings
  • I changed all my sprites’ material from Sprite-Default to Sprite-Lit-Default

Here is how everything is set up:

enter image description here

In fact, I can see results in my scene when I add lights to my objects. For example, here I have a PointLight2D set to a SortingLayer called “Enemy”. You can see that it properly lights the enemy sprite which is also set to that SortingLayer.

enter image description here

enter image description here

The problem is that even with no other lights in the scene, if you toggle the PointLight2D TargetSortingLayers to “None” (or simply some other SortingLayer that doesn’t include “Enemy”), the enemy sprite in the scene still appears fully lit, which seems very odd. For example,

enter image description here

If, on the other hand, you simply disable the light, you see fully unlit sprites, which is what you’d expect.

enter image description here

So my question is why does setting a light’s TargetSortingLayers to “None” (or simply a different layer than your sprite) not result in a fully unlit sprite, but rather a fully lit sprite?

I am wondering whether it is simply intentional behavior that I don’t understand, or possibly a bug in URP.

This behavior is reproducible in a brand new 2D project that you download the Universal Render Pipeline into with both PointLight and GlobalLight (haven’t tried other types of lights).

Related questions from elsewhere on the web, with no resolution:

  1. URP 2D lights not working as expected

Source link

More To Explore

Share on facebook
Share on twitter
Share on linkedin
Share on email