Why is the shadow in the wrong place? (Three.js)

I have a green plane and a red cube above it. Light is directional light.

shadow

Why is the shadow in the wrong place? Code: http://jsfiddle.net/pD8dn/


Edit:

If I change light.shadowBias , the shadow on the plane is correct, but the shadow on the cube is incorrect:

shadow

http://jsfiddle.net/pD8dn/4/

Thanks in advance,

+6
source share
1 answer

This is one of the most common shadow map artifacts called Peter Panning.

The workaround is to add a small offset to test the depth:

 light.shadowBias = 0.001; 

The exact amount of displacement must be adjusted for each scene (and, unfortunately, sometimes you can’t get rid of all artifacts everywhere, setting up shadow maps is more art than science).

This is what works for your example:

http://jsfiddle.net/pD8dn/2/

+6
source

Source: https://habr.com/ru/post/918552/


All Articles