Using CSM I see a lot of dithering

Why does CSM have this effect on meshes?

 var dir = new BABYLON.Vector3(1, -2, 1);
    var light = new BABYLON.DirectionalLight("DirectionalLight", dir, scene);

    light.position.x = -12.507
    light.position.y = 11.798;
    light.position.z = 0.940

    light.direction = new BABYLON.Vector3(0.711, -0.703, -0.008)

    let shadow = new BABYLON.CascadedShadowGenerator(1024, light);
    shadow.lambda = 0.2;
    shadow.autoCalcDepthBounds = true;
    shadow.darkness = 0;
    // shadow.debug = true;
    light.intensity = 4;
    shadow.splitFrustum();
    scene.debugLayer.show({
        embedMode: true,
    });


//AND THEN FOR EACH MESH - snippet example
     sc.meshes.forEach(m=>{
            m.receiveShadows = true;
            shadow.getShadowMap().renderList.push(m);
        })

Code seems fine as shadows do appear, but you also get this dithering

Welcome aboard!

It is probably shadow acne: try increasing the bias value of the shadow generator.

Also, this doc also includes a troubleshooting section that can help you solve shadow problems:

2 Likes

I would also play with the normal bias to prevent peter panning when setting the bias.

1 Like

Neither of those solutions have helped so far, I will prepare a playground to solve it.

2 Likes