编程语言
首页 > 编程语言> > javascript-使用标准MeshPhongMaterial的阴影中的伪像

javascript-使用标准MeshPhongMaterial的阴影中的伪像

作者:互联网

我有一个关于阴影的问题.
这是我面临的问题的图像:

An image is waaay better than a thousand words

enter image description here

我不明白为什么那里有这些线,应该完全点亮了!我不明白为什么实际阴影看起来真的很平滑,并且边框足以满足我要尝试的操作,但是我到处都有这些线条.

我的灯光配置:

var dirLight = new THREE.DirectionalLight(0xfeffaf, 1);
dirLight.position.set(dimensions.middlePoint.x, 
    dimensions.middlePoint.y + ( dimensions.lengthY / 2),
    dimensions.middlePoint.z + dimensions.lengthZ);
dirLight.target.position.set(
    dimensions.middlePoint.x, 
    dimensions.middlePoint.y, 
    dimensions.minZ);
dirLight.castShadow = true;
dirLight.shadowDarkness = 0.4;
dirLight.shadowMapWidth = 1024;
dirLight.shadowMapHeight = 1024;
dirLight.shadowCameraNear = 1;
dirLight.shadowCameraFar = dimensions.lengthY * 2;
dirLight.shadowCameraLeft = - dimensions.lengthX / 2;
dirLight.shadowCameraRight = dimensions.lengthX / 2;
dirLight.shadowCameraTop = dimensions.lengthY / 2;
dirLight.shadowCameraBottom = -dimensions.lengthY / 2;
dirLight.shadowBias = 0.0000005;
scene.add(dirLight);

然后是我的渲染配置:

threeRender = new THREE.WebGLRenderer({ antialias: true });
threeRender.shadowMap.enabled = true;
threeRender.shadowMap.renderReverseSided = false;
threeRender.shadowMapSoft = true;
threeRender.shadowMapType = THREE.PCFSoftShadowMap;

请让我知道如何解决此问题,并指出正确的方向来解决它.非常感谢你.

解决方法:

增加您的shadowBias的价值.该伪影称为暗疮粉刺:

enter image description here

有关更多详细信息,请参见this link.

标签:three-js,shadow,javascript
来源: https://codeday.me/bug/20191118/2028762.html