I’ve spent almost days on this one already … so I kindly ask for your help!
Since r132, it seems to be possible to have self-shadowing in geometry that has a displacementMap applied (see DisplacementMap with Shadow - Three.js Tutorials).
Using debug textures in r132, I get the following (correct) result using MeshPhongMaterial (the shadow casts from the grid structures – please ignore the block structures in the front):
Up to r131, I had a custom depth material that enabled the same functionality (customized to a RGBA elevation texture that I’m decoding in the shader – which is why I can’t work with out-of-the-box MeshPhongMaterial), which now stopped working since r132. In one of many attempts to fix this, I tried to get a custom ShaderMaterial up and running, based on ShaderLib.phong. While the displacement mapping happens (displaced geometry can be seen in the following screenshot’s grid lines), there is no shadowing.
Up to now, I tried out various defines, I’m setting the textures on “material level”, etc. – but I can’t get self-shadowing to work. It seems that there’s some define missing or some other flag off. I feel like I’m almost there but I’m not.
Here’s the current code for the screenshot above (mind some random defines I tried out unsuccessfully):
this.mesh.receiveShadow = true;
this.mesh.castShadow = true;
const terrainMaterial = new THREE.ShaderMaterial(THREE.ShaderLib.phong);
terrainMaterial.defines = {
USE_UV: "",
USE_MAP: "",
USE_BUMPMAP: "",
USE_DISPLACEMENTMAP: "",
VERTEX_TEXTURES: "",
};
terrainMaterial.lights = true;
terrainMaterial.fog = true;
terrainMaterial.extensions.derivatives = true;
terrainMaterial.extensions.fragDepth = true;
terrainMaterial.map = TerrainTile.TextureLoader.load("img/grid512.png");
terrainMaterial.uniforms.map.value = TerrainTile.TextureLoader.load("img/grid512.png");
terrainMaterial.displacementMap = TerrainTile.TextureLoader.load("img/grid512.png");
terrainMaterial.uniforms.displacementMap.value = TerrainTile.TextureLoader.load("img/grid512.png");
this.mesh.material = terrainMaterial;
this.mesh.material.needsUpdate = true;
Why are there no shadows? 


