Here’s the code in the playground
Added two lines (65-66)
shadowGenerator.useBlurExponentialShadowMap = true;
shadowGenerator.blurScale = 4;
Thank you. What if I wanted to make the shadows darker? Also, it’s working if I change the map size of shadow generator from 1024 to 8192. Should I do that? Or is this method the better one??
As for shadow darkness - I’ll quote Deltakosh post from the old forum:
So how shadows work?
Realtime shadows used in Babylon.js use a texture to determine distance between every pixel (that the light can see) and the light. During mesh rendering, shaders compute the current distance of every pixel to the light.
IF this distance is greater than the one saved inside the texture this means that the light CANNOT see the pixel so shaders know they can skip lighting phase for this specific pixel
Long story short
Shadows work like in the real word: by not computing the light. Which means that you cannot control the “darkness” because the shadow is not painted or rendered. You can see a shadow because light is not applied where the shadow is.
For example, here Babylon.js Playground is very good example of different shadows darkness from the same object.
If you changed the shadow map size to 8192, you definitely will notice how FPS will drop. So while the bigger shadow map size gives better quality, for the sake of FPS it is better to use blur filters to achieve even better and realistic results.
Here I made some tweaks with your example - added floor texture, made meshes bigger and, most important, put the light much closer (from y=500 to 50) https://www.babylonjs-playground.com/#LBYR0F#4
Yeah the FPS dropped a lot. Putting the light closer makes a significant difference. The shadow explanation is also pretty neat. Thanks for the help!