I don’t think you miss anything. It is probably losing of precision when the light is far away. Is it ok if you use more than one light? A hemisphericLight for the entire world, and your directional light always follow your model for the shadow cast. You may need to adjust the intensity property of the lights to get it right.
You are correct, it seems that you have to move the light with the caster. Thanks for your help.
My problem was that I had another caster in the scene - so moving away from the other caster caused an increase in the area the shadow map had to cover.
I created this scene for interest to show what I mean.
Sorry. When I saw your follow up question my family was waiting for me to go out. My understanding of your question is if you have more than one model in the scene, it is not right to let the sunlight to follow one of the models in the scene.
I am not sure if this approach works for you: can you try to keep you sunlight at the position of the camera. So the shadows close to the models are always smooth. As you model walk further away from camera or for models that are far away from the camera, the detail doesn’t matter that much. Please see the following PG:
// var shadowGenerator = new BABYLON.CascadedShadowGenerator(1024, light);
// shadowGenerator.splitFrustum();
and
var shadowGenerator = new BABYLON.ShadowGenerator(1024, light);
For a large number of meshes, ShadowGenerator is doing much better. But if you increase the resolution of ShadowGenerator to 4096. FPS is similar to CascadedShadowGenerator. But CascadedShadowGenerator renders much smoother shadows. So increase resolution of the shadow texture probably doesn’t make sense.
For a fair comparison, you should enable PCF filtering + high quality on the standard shadow generator because it’s the default setup when using a cascaded shadow generator. You should also set a texture size of 2048, as by default CSM uses 4 textures the size you pass in parameter: 4x1024x1024 = 2048x2048.
By doing so, you will see that the standard shadow generator is actually not worst than CSM, if not better: