Hi,
I am still learning Babylon JS and I’m facing an issue with shadows. I have a ground receiving shadows, and cones casting shadows. The light is a directional light.
var light = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(1, -2, 1), this.scene);
light.position = new BABYLON.Vector3(-1, 2, -1);
light.intensity = 0.5;
var shadowGenerator = new BABYLON.ShadowGenerator(1024, light);
ground.receiveShadows = true;
var cone = BABYLON.MeshBuilder.CreateCylinder("test", {diameterBottom: diameterBottom, diameterTop: diameterTop, height: height, tessellation: tesselation}, scene);
What I don’t understand is that if the cone is “too small”, then there is either no shadow cast, or one very imprecise. If I scale my cone up, then the shadow is rendered.
Below you can see my scene rendered first with my initial arbitrary scale (the smaller cones do not even have a shadow), then with everything scaled x10, and finally scaled x100.
With everything scaled x10, the smaller cones do have a shadow, though very imprecise. It seems that scaling up more does not change the quality of the shadow. Diameter for the cone on scale x1 is 0.18 to 0.05, height is 0.25. I know it’s “small” but I also thought that in 3D engines unit scaling was arbitrary.
1/ Why is the shadow so imprecise/jagged/aliased? Is there a setting to make it more accurate? (it might be as simple as a boolean to set somewhere on the shadow generator but I’ve been going through the docs, and I probably missed it)
2/ It seems that there is a “minimum” scale at which the shadow is cast. Why? Does that mean I should not have objects smaller than “1”?
Thanks!
EDIT: I noticed that if I change the size of the shadow map from 1024 to 8192, I get acceptable shadows when my scene is scaled x10. I suppose that makes sense in terms of precision. But I still have no shadow at all on scale x1 and I don’t understand why.
EDIT: reproduced here: https://playground.babylonjs.com/#15UN5M#2