# How can I get good shadows

**URL:** <https://forum.babylonjs.com/t/how-can-i-get-good-shadows/3195>\
**Category:** Questions\
**Tags:** tutorial\
**Created:** [May 14, 2019, 1:22pm UTC](https://forum.babylonjs.com/t/how-can-i-get-good-shadows/3195 "2019-05-14T13:22:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fshihu](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/fshihu/32/2301_2.png) [@fshihu](https://forum.babylonjs.com/u/fshihu)\
**Post date:** [May 14, 2019, 1:22pm UTC](https://forum.babylonjs.com/t/how-can-i-get-good-shadows/3195/1 "2019-05-14T13:22:10Z")

</div>

I tried a lot  
[https://www.babylonjs-playground.com/#164IC3#2](https://www.babylonjs-playground.com/#164IC3#2)

for(var i =0; i \< 100;i++){  
change to  
for(var i =0; i \< 10;i++){

- The shadows are getting better

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [May 14, 2019, 2:03pm UTC](https://forum.babylonjs.com/t/how-can-i-get-good-shadows/3195/2 "2019-05-14T14:03:25Z")

</div>

Hello and welcome!  
The problem you are facing is due to the fact that your shadow map will lose a lot of precision to make sure it can embrace the entire scene.

Ideally we should have cascaded shadow maps to help with your case (wink wink @sebavan) but we do not support this feature yet.

So the idea is to keep in the shadow map only the meshes close to the camera. In any way this will be far better from a performance standpoint

---

<div class="post-metadata">

**Author:** ![fshihu](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/fshihu/32/2301_2.png) [@fshihu](https://forum.babylonjs.com/u/fshihu)\
**Post date:** [May 15, 2019, 1:30am UTC](https://forum.babylonjs.com/t/how-can-i-get-good-shadows/3195/3 "2019-05-15T01:30:02Z")

</div>

Thanks!

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

Actually I use it in buildings. They are a mesh.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [May 15, 2019, 2:28pm UTC](https://forum.babylonjs.com/t/how-can-i-get-good-shadows/3195/4 "2019-05-15T14:28:30Z")

</div>

Does the light move? Because if it does not move it could be worth baking the shadows into a texture so you can have the best rendering

---

<div class="post-metadata">

**Author:** ![Wingnut](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wingnut/32/53_2.png) [@Wingnut](https://forum.babylonjs.com/u/Wingnut)\
**Post date:** [May 15, 2019, 2:36pm UTC](https://forum.babylonjs.com/t/how-can-i-get-good-shadows/3195/5 "2019-05-15T14:36:39Z")

</div>

But DK… with baked-into-ground-texture building-shadows… user-carried flashlights/torches… cannot illuminate shadowed areas. 😉 (small price to pay, for huge added performance of baked shadows… I know) 🙂

I think user will ALSO lose building shadows on OTHER buildings… with baked shadows on ground.

(Wingy prices supercomputers) 🙂

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [May 15, 2019, 2:40pm UTC](https://forum.babylonjs.com/t/how-can-i-get-good-shadows/3195/6 "2019-05-15T14:40:34Z")

</div>

Yes I agree. If the op needs a dynamic shadow then we need to decouple the mesh into multiple meshes (like block by block for instance)

---

<div class="post-metadata">

**Author:** ![Wingnut](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wingnut/32/53_2.png) [@Wingnut](https://forum.babylonjs.com/u/Wingnut)\
**Post date:** [May 15, 2019, 2:46pm UTC](https://forum.babylonjs.com/t/how-can-i-get-good-shadows/3195/7 "2019-05-15T14:46:24Z")

</div>

Yeah, essentially you are saying… “Don’t let the camera do such a WIDE view”. Keep things close-in… as much as possible, and do render-only-what’s-needed wisdom. nod. Tiling ops.

City is currently single mesh, huh? Interesting.

---

<div class="post-metadata">

**Author:** ![fshihu](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/fshihu/32/2301_2.png) [@fshihu](https://forum.babylonjs.com/u/fshihu)\
**Post date:** [May 16, 2019, 10:52am UTC](https://forum.babylonjs.com/t/how-can-i-get-good-shadows/3195/8 "2019-05-16T10:52:40Z")

</div>

Is there a good way to separate the mesh?
