使用于平行光,大型场景。
let light=new BABYLON.DirectionalLight('dir',new BABYLON.Vector3(0,-1,1),scene)
light.position.y=10000
var shadowGenerator = new BABYLON.CascadedShadowGenerator(1024, light);
shadowGenerator.getShadowMap().renderList.push(sphere);
camera.maxZ = 1000;
shadowGenerator.splitFrustum();
ground.receiveShadows = true;
//练级数,简单点说就是相机距离越远,阴影变化的次数,从清晰到模糊的过度
shadowGenerator.numCascades=4
//lambda是设置模糊度的
shadowGenerator.lambda=1
//练级混合百分比,就是联级之间的混合过度
shadowGenerator.cascadeBlendPercentage=1
//相机旋转时阴影会跳动,通过设置可以避免跳动,也就是稳定连级
shadowGenerator.stabilizeCascades=true
/*
*启用后,它会提高阴影质量,因为不需要调整不同级联光锥的近
* 平面来考虑远处的阴影投射器。
*请注意,此属性与 PCSS 过滤不兼容,因此在这种情况下不会使用它。
*/
shadowGenerator.depthClamp=true
//启用后不同连级会以不同颜色显示
shadowGenerator.debug=true