Seimouun
Seimouun

Reputation: 21

THREE.JS displacement map not affecting shadows

I'm struggling with getting the shadows working correctly with a displacement map. I've looked the problem up on Google and as far as I understand, the displacement map distorts the vertices. So in theory there shouldn't be a problem.

However, the displacement map has no effect on the shadows. image of the problem

Upvotes: 2

Views: 307

Answers (1)

Mugen87
Mugen87

Reputation: 31026

Try using a custom depth material on your shadow casting sphere like so:

sphere.customDepthMaterial = new THREE.MeshDepthMaterial( {
    depthPacking: THREE.RGBADepthPacking,
    displacementMap: displacementMap,
    displacementScale: displacementScale,
    displacementBias: displacementBias

});

Upvotes: 4

Related Questions