Directionallight vs Spotlight soft shadows

Hi,
I don’t really understand why the shadow computation behaves like it does. I’ve created a PG to show the problem: https://playground.babylonjs.com/#B48X7G#48

I’m using the PCSS shadow which works fine if I use a spotlight but the soft shadow gets basically completely hard if I use a directional light. Simply comment in/out the SpotLight/DirectionalLight in the PG to see what I mean.

Hope someone can explain to me what’s going on there.

ping @sebavan

The main issue is that a directional light is fully orthographic so there is no “diffusion” on the edge as we can see in a spot resulting from the projected angle.

@Evgeni_Popov might have more tricks ???

1 Like

No, I don’t really know. I tried with a blurred exponential filter but it’s no better.

Ohhhhh no I am dumb it is because the texture is currently to close from the object as their is only one.

https://playground.babylonjs.com/#B48X7G#49

@Evgeni_Popov do you remember how we can force a specific frustrum for the lights ?

You must set light.autoUpdateExtends=false then set the light.orthoLeft/orthoRight/orthoBottom/orthoTop properties:

https://playground.babylonjs.com/#B48X7G#51

But doing so the blurriness comes from the decreased precision of the shadow map so there is a limit to using it…

1 Like

This doesn’t seem to do the trick either. If I remove the other boxes from the shadowgenerator the shadow is again hard: https://playground.babylonjs.com/#B48X7G#52

For me the shadow is the same in the two cases:

|

I’m using 4.2. If I use the latest version in the PG then it works as well. Unfortunately I’m currently bound to 4.2. :frowning:
Any idea what I could do else?

In 4.2, the light.orthoLeft/orthoRight/orthoBottom/orthoTop properties were not exposed, so you must use the private properties instead light._orthoLeft/_orthoRight/_orthoBottom/_orthoTop:

https://playground.babylonjs.com/#B48X7G#53

Oh - how could I’ve not seen that. :grinning: I guess I can work with that - thx for the quick replies!

1 Like