A mesh casting shadow looking too dark after enabling shadow reception

Hello all,

I am back to creativity after having spent all my spare time into gaming (finished Elden Ring, Diablo 4, Cyberpunk 2077, Baldur’s Gate 3, etc) :sweat_smile:

Next to my card game, I have now the new project to make the best looking scrabble game ever (what else :p) thanks to babylonjs, and after just one week, I am blown away by the results :wink:

My problem is that I would like to have the letters both casting shadows AND receiving shadows, but as soon as I combine both, the letters become dark, and don’t look to receive shadows anyway (was thinking there could be some problems with the light, but apprently not).

On that screenshot and demo you can try here Vite App the letters on the support letter are shadow casters this.shadowGenerator.addShadowCaster(letter.mesh); but are not yet receiving shadows. The letters already on the board are the opposite, just receiving shadows letter.mesh.receiveShadows = true;

When drag and dropping a letter from the support to the board I try to enable the shadow reception (ideally, would have both casting and recepting all time…)

Any idea why ?

I managed to reproduce it on the playground for shadow demo here https://playground.babylonjs.com/#IFYDRS#704

Adding this on line 62 torus.receiveShadows = true; and the torus is also becoming dark…

You must increase the shadowGenerator.bias value to avoid self shadowing. The easiest way is to use the inspector, so that you can see the result of the changes in realtime. When you found the right value, just set it in code.

Hi and thank you for the quick and accurate answer!

I see the more I increase the bias the weaker is also the shadow applied by all my meshes until I find the correct bias that is no more altering the letter color but then the shadow displayed by all the casters become too weak to be seen…

Is there another parameters I can play with to increase the shadow strength ?

You have the ShadowGenerator.darkness property to set the “blackness” of the shadows.

I think this page of the doc can help you:

Thanks, so I tried and nothing was working until I commented this line this.shadowGenerator.useBlurExponentialShadowMap = true; inherited from a previous project :slight_smile: