Smaller meshes don't cast shadows

Hi all -
I’ve got a peculiar problem where shadows aren’t showing up when a mesh is small - but are showing up fine if mesh is big.

In screenshot, all i’ve done is adjust the scaling of the player in the inspector - and as you can see, the larger character is casting a shadow, but the little one is not.

Where shadow generator is:

this.shadowGenerator = new BABYLON.ShadowGenerator(1024, this.light_dir);
this.shadowGenerator.usePercentageCloserFiltering = true;
this.shadowGenerator.setDarkness(0.02);
this.shadowGenerator.bias = 0.0005;

Is there a some setting that enables smaller objects to cast shadows?

PG: set scaling of player1 to 1 to see shadow:

Interesting - the problem looks like it’s a function of distance from the ground. In screenshot below, i’ve just moved the ground further away from the player - and the shadow shows up:

Some ways that should work:

  1. add shadow map size
  2. limit shadow maxz and shadow minz
  3. change to cascaded shadow generator
1 Like

Awesome - setting the Min/Max solves it (although it seems a bit unsmooth)

Will need to play more with the cascade - not quite working:

You need to increase lambda or enable autoCalcDepthBounds to have more space in shadow map for meshes that near the mesh when using cascaded.

2 Likes

Wow, that looks a TON better. Thx so much for the pointers.

1 Like