# Problem with ShadowGenerator

**URL:** <https://forum.babylonjs.com/t/problem-with-shadowgenerator/12709>\
**Category:** Questions\
**Tags:** documentation, lighting\
**Created:** [July 21, 2020, 2:26pm UTC](https://forum.babylonjs.com/t/problem-with-shadowgenerator/12709 "2020-07-21T14:26:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheNosiriN](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/thenosirin/32/11803_2.png) [@TheNosiriN](https://forum.babylonjs.com/u/TheNosiriN)\
**Post date:** [July 21, 2020, 2:26pm UTC](https://forum.babylonjs.com/t/problem-with-shadowgenerator/12709/1 "2020-07-21T14:26:00Z")

</div>

I have a slight problem with the ShadowGenerator. The shadow map, with a fixed size, stretches itself to render on all the meshes in it’s **renderlist** giving ultra low quality shadows:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/8/8fbcc7f47b4f20b8bcff52ae73ce82fe4e8aa040.jpeg)  
which is understandable.

So I tried to make a workaround, by placing LOD ShadowGenerators and switching meshes in their render list based on their distance to the player, but of course all the shadowgenerators need a way of finding meshes outside their shadow map to cast shadows so I used this on every mesh while testing on just one shadow gen:

`this.mesh.receiveShadows = true; game.shadowGenerator.addShadowCaster(this.mesh);`

and using this code to switch them:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/9/9ab6aaa04eb0bfc1ae73b70884f265831fac0f8d.png)

However, **addShadowCaster** also adds the mesh to the renderlist, I thought it was just meant to recognize it as something that cast shadows, even if you comment out that switch code it still renders shadows on the shadow caster. Maybe I’m missing something or typing something wrong but I need help.

---

<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:** [July 21, 2020, 3:23pm UTC](https://forum.babylonjs.com/t/problem-with-shadowgenerator/12709/2 "2020-07-21T15:23:09Z")

</div>

I’m not sure I understand…

`addShadowCaster(mesh)` simply does a `renderList.push(mesh)`, so if you are handling the `renderList` list yourself you should not call `addShadowCaster`.

---

<div class="post-metadata">

**Author:** ![TheNosiriN](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/thenosirin/32/11803_2.png) [@TheNosiriN](https://forum.babylonjs.com/u/TheNosiriN)\
**Post date:** [July 21, 2020, 3:43pm UTC](https://forum.babylonjs.com/t/problem-with-shadowgenerator/12709/3 "2020-07-21T15:43:11Z")

</div>

How do I make it cast shadows without adding it to the renderlist, because adding it to the renderlist stretches the shadow map.

---

<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:** [July 21, 2020, 3:50pm UTC](https://forum.babylonjs.com/t/problem-with-shadowgenerator/12709/4 "2020-07-21T15:50:27Z")

</div>

You can’t: the `renderList` is the list of shadow casters, if you don’t put a mesh in it it won’t cast shadows.

For the shadow map technic to work, the light volume must encompass at least all the shadow casters, no way around that. However, you can make sure your light volume is as tight as possible, that will improve the quality of the shadows.

See for eg [Blender exporter shadows not working properly](https://forum.babylonjs.com/t/blender-exporter-shadows-not-working-properly/12657/5)
