THREE.js spotlight casting shadow with no object between the near plane and the receiver

邮差的信 提交于 2019-12-24 13:24:47

问题


I'm having troubles with getting shadows to work in three.js . On the image below you can see a spotlight casting a shadow on an object with plane geometries. There is no object in between the spotlight near plane and the plane geometries of the wall.

What can cause such behavior?

The light is configured this way:

var spotLight = new THREE.SpotLight(0xFFFFFF, 1);
spotLight.position.set(0, -20, 100);
spotLight.target.position.set(0,0,0);
spotLight.shadowDarkness = 0.5;
spotLight.shadowCameraVisible = true;
spotLight.castShadow = true;
spotLight.shadowMapWidth = 1024;
spotLight.shadowMapHeight = 1024;

spotLight.shadowCameraNear = 10;
spotLight.shadowCameraFar = 200;
spotLight.shadowCameraFov = 10;
spotLight.shadowBias = 0.1;
scene.add(spotLight);

The rectangular meshes are BufferGeometries converted from PlaneGeometries with an png uv mapped image as the texture with .receiveShadow set to true.

THREE.js version r71.

Any help will be very much appreciated.


回答1:


Maybe it is self-shadowing, try to play with spotLight.shadowBias. Usually, a value of 0.05 is used for avoid self-shadowing.



来源:https://stackoverflow.com/questions/31514344/three-js-spotlight-casting-shadow-with-no-object-between-the-near-plane-and-the

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!