我创建了一个简单的基于Phong的自定义着色器,它可以根据光度创建不透明度。现在,当我试图添加法线贴图功能时,WebGL会给我带来错误。
var vertexShader = THREE.ShaderLib.phong.vertexShader;
var fragmentShader = getShader();
var uniforms = THREE.UniformsUtils.clone(THREE.ShaderLib.phong.uniforms);
var defines = {};
defines[ "USE_MAP" ] = "";
defines[ "USE_NORMALMAP" ] = "";
var color_map = loader.load( 'img/colored.jpg' );
var normal_map = loader.load( 'img/skin_normal.jpg' );
uniforms.map = { type: "t", value: color_map};
uniforms.normalMap = { type: "t", value: normal_map};
uniforms.normalScale = { type: "v2", value: new THREE.Vector2( 0.25, 0.25 )};
如果我注释掉USE_NORMALMAP,一切都按预期工作(显然没有正常的地图),但是如果它已经启用我得到了这个:
three.js:16058 THREE.WebGLShader: Shader couldn't compile.Gt @ three.js:16058Kt @ three.js:16578acquireProgram @ three.js:16996w @ three.js:21057E @ three.js:21214renderBufferDirect @ three.js:20163b @ three.js:20986render @ three.js:20727render @ VREffect.js:396value @ a-scene.js:425(anonymous function) @ bind.js:12
three.js:16612 THREE.WebGLProgram: shader error: 0 gl.VALIDATE_STATUS false gl.getProgramInfoLog invalid shaders ERROR: 0:684: 'GL_OES_standard_derivatives' : extension is disabled
ERROR: 0:685: 'GL_OES_standard_derivatives' : extension is disabled
ERROR: 0:686: 'GL_OES_standard_derivatives' : extension is disabled
ERROR: 0:687: 'GL_OES_standard_derivatives' : extension is disabled
我假设它是因为我没有在着色器中加载某些东西或者以错误的格式以某种方式传递normalMap和normalScale。可能导致这种情况的原因是什么?