three.js 中对象上的 Janky 阴影

Janky shadows on objects in three.js

我正在尝试平滑场景中对象的阴影

这是一张图片:https://imgur.com/UFXTxSG

和我的Github:https://github.com/mat148/shoeVR

下面是一些与阴影有关的代码:

renderer.shadowMapEnabled = true;
renderer.shadowMapType = THREE.PCFSoftShadowMap;

firePillar.castShadow = true;
firePillar.receiveShadow = true;

var directionalLight = new THREE.DirectionalLight(0x007c9a, 0.5);
directionalLight.position.set(500, 704, 0);
directionalLight.castShadow = true;

阴影很难正确。由于您需要考虑哪些网格正在创建阴影以及它们是否接收到阴影等等。

ShadowBias 肯定是可以玩的东西。

尝试

renderer.shadowMapSoft = true;
//Your shadow casting light source
spotlight.castShadow = true;
spotlight.shadowBias = - 0.001;
// This increases the resolution of your Shadow maps. 
spotlight.shadowMapWidth = 2042;
spotlight.shadowMapHeight = 2042;