Problem with ShadowGenerator

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:

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:

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.

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.

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

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

1 Like