In this playground, I want to create shadows for the house, but there are some wrong shadows appearing on the ground. I want to know the reason. Is it the reason why I set the receiveShadows of all meshes to true?
The light frustum is too big, because it encompasses the large ground:
If you remove the large ground from the list of shadow casters, the frustum will be smaller:
And you will get better shadows:
Thank you very much for your reply. This is a great method, but if you don’t know which node will affect the shadow more. For example, I want someone to upload a model to add shadows to it, and I want the quality of the shadow to be as high as possible. How should I do it?
Maybe this post can help, at least to compute the position of the light and the minZ/maxZ properties:
You can disable the automatic calculation of the light frustum extents (
light.autoUpdateExtends = false) and calculate the
orthoLeft/orthoRight/orthoTop/orthoBottom properties yourself, based on the scene’s bounding box, but limiting the values if they are too high (to avoid losing precision in the shadow map). If you do this, you may not get shadows for the most distant objects, but there are trade-offs. You can also try using [cascading shadow maps] (Cascaded Shadow Maps | Babylon.js Documentation).
Thanks again for your reply, it’s exactly what I needed!