Does a ShadowGenerator have a range?

Sometimes, when the light source is too far away, the ShadowGenerator stops creating shadows. I haveput a couple of boxes in this scene, and you see that those further on the left do not have shadows. When I move the light source further to the left, box on the left also get shadows like the boxes on the right.

What can I do to have shadows on ALL boxes?

Hey, you have to move the light so it could see all of the meshes. But by doing that you will reduce the precision up to a point where shadows will not be able to render

So in this case you need to increase the shadow resolution

We hope to be able to add support for cascaded shadow maps one day as it will directly fix that issue (pinging @sebavan fyi ;))

1 Like

Strange. I don’t know much about shadow mapping, maybe I don’t understand it correctly.

I have created a small playground: https://www.babylonjs-playground.com/#IFYDRS#40

This box has two shadows: One looks strangely rasterized, the other shadow occurs on two opposite sides of the same box, something that cannot be true for a directional light, I thought.

What am I missing?

You can use the Inspector to see the content of the shadow maps:

As you can see the precision of your second shadow map is not good (the mesh is a tiny dot) because the light is too far

OK, sure, the second shadow map is bad. But how does the first happen to be displayed on both sides of the same box? Shadows should normally appear on one side of a convex body, only.

This one is an unfortunate artifact due to the exponential filter.

https://www.babylonjs-playground.com/#IFYDRS#42

1 Like

Thanks, @Deltakosh, for your help. I turned the far away point light (the sun) into a nearby directional light, and now each and every box has its shadow on the terrain, as expected:

I see the next programming task for me: “Make the boxes look more like houses, not like a graveyard.” :slight_smile:

2 Likes

Oh and by the way, TWIMC, I stumbled across an interesting web page about shadows:

http://codeflow.org/entries/2013/feb/15/soft-shadow-mapping/

1 Like

Hi @Deltakosh, how can I activate this panel in my own BJS app? Would be nice for debugging.

scene.debugLayer.show();

https://www.babylonjs-playground.com/#IFYDRS#43 (added at line 49)

https://doc.babylonjs.com/how_to/debug_layer

1 Like