Hello guys.
I have kind of a “simple” issue here… steps to reproduce:
- Set up two identical Directional Lights (Realtime for simplification).
- Point each light to different layers, say one for Default and another for Water.
- Create two identical objects and change one to Water layer (both with Cast Shadows ON obviously).
For some reason the second light won’t generate shadows at all (but still light the object):
I did some research and it may be related to limitations of light amount in the scene, but I couldn’t fix it with any solutions I tried.
It feels like a bug… or am I doing something wrong here?
Hi Valasty,
Based on the information you gave, I believe your problem stems from the fact that Multiple Directional Light Shadows are not supported on URP/HDRP. (Here’s a source if you’re interested)
Oh, that’s interesting, I didn’t know that. Thanks for the info!
@Layla-A , as per documentation there should be no limitations for Spot/Point lights, but they won’t work as well:
The setup is the same as above, each object in a different layer, each light casting to each specific layers. I don’t quite understand why would lights on different layers cancels each other…
The reason I need this is because I have 2D charactes in a 3D world, so I want to have a light to simulate the environment lighting, and another light specifically to force a shadow in the ground directly beneath the character.
Hmm, I tested this out quickly on my end and it seems like it works. Does the plane have the correct light layers checked off? e.g.
I have never changed the Renderying Layer Mask of the objects, they are both on “Light Layer Default”, just the second cube is set to Water in the Layer tag itself:
The other cube is set to “Default” layer.
Then the Spot Light is set with Culling Mask = only Water, while the Directional is set to everything BUT Water.
What version of Unity are you on?
I would recommend fiddling a bit with your scene setup as the shadow for the spotlight appears quite light, depending on the intensity of the directional light.
If that doesn’t work - I’m assuming you’re on URP - in your URP asset, is this field checked off?
I’m on 2022-2, this setting is on, yes.
Are you setting each object with a different layer? It looks like they are both on the same one.
Cube 1 and ground: default layer
Cube 2: water layer
Directional Light culling mask = everything but water
Spot Light culling mask = only water
It seems like the differences we’re getting might be due to rendering path (e.g. Forward vs Forward+)
Regardless, to get the behaviour you’re looking for, I would recommend using Rendering Layers/Rendering Layer Masks. Culling masks should be used to control which lights are culled per camera, whereas Rendering Layers allow you to selectively decide which lights affect which objects. This works on all rendering paths.
Got it, I will look into this, thanks!
1 Like