# Shadow display error issue

**URL:** <https://forum.babylonjs.com/t/shadow-display-error-issue/47751>\
**Category:** Questions\
**Created:** [February 2, 2024, 6:09am UTC](https://forum.babylonjs.com/t/shadow-display-error-issue/47751 "2024-02-02T06:09:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xuyang\_yuan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/xuyang_yuan/32/37254_2.png) [@xuyang\_yuan](https://forum.babylonjs.com/u/xuyang_yuan)\
**Post date:** [February 2, 2024, 6:09am UTC](https://forum.babylonjs.com/t/shadow-display-error-issue/47751/1 "2024-02-02T06:09:47Z")

</div>

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?

> **[Babylon.js Playground](https://playground.babylonjs.com/#KBS9I5%2335000)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 2, 2024, 11:04am UTC](https://forum.babylonjs.com/t/shadow-display-error-issue/47751/3 "2024-02-02T11:04:28Z")

</div>

The light frustum is too big, because it encompasses the large ground:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/c/bc69ac68dd4732ad8ec7db23a5f6963b51692524.jpeg)

If you remove the large ground from the list of shadow casters, the frustum will be smaller:

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/c/1caebc115bd8b45ad1440fcee420028b8f9f3d12.jpeg)

And you will get better shadows:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/7/e/7ef80e8d6931260306db344e86c23266ca4ee5a2.jpeg)

> **[Babylon.js Playground](https://playground.babylonjs.com/#KBS9I5%2335007)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![xuyang\_yuan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/xuyang_yuan/32/37254_2.png) [@xuyang\_yuan](https://forum.babylonjs.com/u/xuyang_yuan)\
**Post date:** [February 4, 2024, 1:57am UTC](https://forum.babylonjs.com/t/shadow-display-error-issue/47751/4 "2024-02-04T01:57:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 4, 2024, 12:54pm UTC](https://forum.babylonjs.com/t/shadow-display-error-issue/47751/5 "2024-02-04T12:54:53Z")

</div>

Maybe this post can help, at least to compute the position of the light and the minZ/maxZ properties:

> [@Best shadow parameters for specific scene](https://forum.babylonjs.com/t/best-shadow-parameters-for-specific-scene/19722/12):
>
> One way to do it is to get the bounding box of the mesh (+sub meshes), compute a bounding sphere for it and use the center of the sphere to compute a point on that sphere in the inverse direction of the light: that will be the light position. The shadow max Z is simply the diameter of the sphere: Be careful, however, because it creates a quite tightly fit frustum of the mesh, but some filtering methods require that the frustum intersects with the mesh receiving the shadow (the plane in the P…

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](https://doc.babylonjs.com/features/featuresDeepDive/lights/shadows_csm)).

---

<div class="post-metadata">

**Author:** ![xuyang\_yuan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/xuyang_yuan/32/37254_2.png) [@xuyang\_yuan](https://forum.babylonjs.com/u/xuyang_yuan)\
**Post date:** [February 5, 2024, 3:30am UTC](https://forum.babylonjs.com/t/shadow-display-error-issue/47751/6 "2024-02-05T03:30:49Z")

</div>

Thanks again for your reply, it’s exactly what I needed!
