Three.js 不同计算机(同一浏览器)上的着色器错误

Three.js shader error on different computers (same browser)

在过去的 3 个月里,我一直在使用 Three.js 进行开发,并且在多个浏览器和计算机上使用它都很好。上周在我的家用电脑上,每当我尝试加载我的网站时都会收到此错误:

three.js:29948 THREE.WebGLProgram: shader error:  0 gl.VALIDATE_STATUS false gl.getProgramInfoLog C:\fakepath(254,9-30): error X3004: undeclared identifier 'IncidentLight'

Warning: D3D shader compilation failed with default flags. (vs_3_0)
 Retrying with avoid flow control
C:\fakepath(254,9-30): error X3004: undeclared identifier 'webgl_45daf4aa877f103d'

Warning: D3D shader compilation failed with avoid flow control flags. (vs_3_0)
 Retrying with prefer flow control
C:\fakepath(254,9-30): error X3004: undeclared identifier 'webgl_45daf4aa877f103d'

Warning: D3D shader compilation failed with prefer flow control flags. (vs_3_0)
Failed to create D3D shaders.

该网站是实时的,不能在少数几台电脑上运行,但可以在工作的电脑上运行。我已确保检查 WebGL 是否已在网站 工作但已启用的浏览器上启用。

这可能是某些硬件的已知问题,出现在新的 Three.js 版本中 - https://github.com/mrdoob/three.js/issues/8161

问题已在 dev 分支中修复。不过有一个解决方法:

Compilation fails on functions IncidentLight getPointDirectLight and IncidentLight getDirectionalDirectLight. Modify those functions to void types:

void getDirectionalDirectLight( out IncidentLight directLight, const in DirectionalLight directionalLight, const in GeometricContext geometry );

void getPointDirectLight( out IncidentLight directLight, const in PointLight pointLight, const in GeometricContext geometry );