I got 3 directional lights and one ambient, and the shadows rendering not really as I expected - I see the “shadow pits” and dark corners, so I wish to remove them. I tried to increase the quality of shadows, but the result was bad.
My dir light setup:
var lightBack = new THREE.DirectionalLight(0xffffff,0.6);
lightBack.position.set(0, 10, -20);
lightBack.target.position.set(0, 0, 0);
lightBack.shadow.camera.near = 0.5;
lightBack.shadow.camera.far = 5000;
lightBack.shadow.camera.left = -500;
lightBack.shadow.camera.bottom = -500;
lightBack.shadow.camera.right = 500;
lightBack.shadow.camera.top = 500;
// lightBack.shadow.mapSize.width = 1024*4;
// lightBack.shadow.mapSize.height = 1024*4;
lightBack.castShadow = true;
You might want to decrease the size of the shadow camera’s view frustum to make shadows more sharp.
THREE.CameraHelper can be useful in this context since it allows you to visually debug the frustum. You can add an instance like so:
scene.add( new THREE.CameraHelper( lightBack.shadow.camera ) );
Modulating LightShadow.bias or LightShadow.normalBias could also help to reduce self-shadowing artifacts.
If all this does not help, consider to use an AO map to implement shadows.
I’m with @Mugen87 on the AO part, but I’d go further and say that in my humble estimation, a high-quality AO map baked from blender with something like 3k samples per texel will yield far superior results than anything you can get out of dynamic shadow maps.
Currently I need to change texture dynamically, so I’m not sure that AO + real time texture changing is compatible.
The AO map would be independent from your texture.
Can you recommend a good tutorial for AO and shadow baking on blender, I’ve been trying but shadows are coming out black? I’ve even considered downgrading blender to 2.8 to use old gltf exporter
here’s a good tutorial on the blender side:
don’t forget to properly export that to GLTF, the notes on that are in the blender documentation itself: