Skip to content

优化阴影性能

先可以添加像机助手,帮助观察: const directionalLightCameraHelper = new THREE.CameraHelper(directionalLight.shadow.camera)

  • 设置灯光阴影大小

调整render的阴影算法

js
light.shadow.mapSize.height = 1024;
light.shadow.mapSize.width = 1024;
  • 缩小阴影像机远近焦距(效果一般)

调整render的阴影算法

  • 调整阴影像机位置(效果明显)

调整render的阴影算法

  • 调整 render 的阴影算法 调整render的阴影算法

最佳算法 renderer.shadowMap.type = THREE.PCFSoftShadowMap

需要注意,pcf 算法不能和 radius 同时使用directionalLight.shadow.radius = 10

Released under the MIT License.