Three.JS: Weird shadow artifacts from a spotlight, but only in Android

穿精又带淫゛_ 提交于 2020-12-12 10:49:29

问题


Using Three.js v0.113.2 I'm rendering this scene of a mug on a plane with two spotlights (one behind, one in front), and an ambient light. The front spotlight casts shadows, the mug is set to cast shadows (but not receive them), and the plane is set to receive shadows. I'm using a shadow radius of 20 (iirc). The shadow mapSize is 1024x1024.

On Android, and only on Android (this renders correctly on iPhones, Windows, and Mac desktops) I see these weird banding artifacts from the lighting on the objects. It's most evident on the mug, but it's present on the pane as well. The artifact has clearly distinguishable lines that do not match up to the geometry of the mug object.

I have tried setting the camera.near and camera.far planes to tightly encapsulate the scene, and ended up with 50/200 for those values. No effect.

I tried setting the shadow.bias value to something very near zero, -.001. Also no effect.

Unfortunately, that was the extent of the suggestions I could find from the Three.js repo and other StackOverflow questions. If this artifacting looks familiar to anyone, I would love to figure out how to fix this.

EDIT: I've set castShadow on the Spotlight to false, removed the ambient light, removed the castShadow and receiveShadow from all meshes, and the artifacting still shows up on Android (only).


回答1:


In case anyone finds this in the future:

The unfortunate artifacting that, at this time, affects only Android, is caused by having the angle value of any spotlight set too low. In the scene above, there was a spotlight with an angle of 0.091. When that was raised to 0.171 the strange banding disappeared.



来源:https://stackoverflow.com/questions/63679178/three-js-weird-shadow-artifacts-from-a-spotlight-but-only-in-android

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