1 year ago

#61951

test-img

moo.h

Unity 2D URP Light: How do I prevent that an object is affected by self shadow of another object

I'm trying to recreate my old 2D top down game (developed with Monogame) in Unity.

For lighting, there is now a usable 2D light (URP) that casts shadows based on the light source in relation to a polygon (same as I used in my old engine).

They even have the "self shadow" feature, as an object that is illuminated (in 2D) from above will naturally appear darker than if it is illuminated from below (front).

But exactly with this function, I have a problem in Unity. An NPC which overlaps with an object with "self shadow" is also darkened.

enter image description here

You can see the shadow shadow from the pillar on the head.

I had exactly the same problem in my old engine. I solved it by excluding the NPCs from the shadow cast and taking the shadow value of one pixel between the feet as the basis for the brightness of the entire NPC. I found an old picture of this problem:

enter image description here

On the left, the problem I have in Unity. On the right is the desired result.

So my question is: How do I prevent that an object is affected by self shadow of another object in Unity (2D Light).

unity-game-engine

2d

shadow

topdown

0 Answers

Your Answer

Accepted video resources