我不是着色器专家,但我想将颜色值传递给可能与环境贴图颜色混合的着色器。
var shader = THREE.FresnelShader;
// Thank you WestLangley for that trick
var uniforms = THREE.UniformsUtils.merge( [
THREE.UniformsLib[ "lights" ],
shader.uniforms
] );
uniforms[ "tCube" ].value = textureCube;
var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights : true };
shaderMaterial = new THREE.ShaderMaterial( parameters );
shaderMaterial.envMap = textureCube;
我一无所知。谢谢你的建议。
对于期货;)您需要首先通过将颜色传递给着色器来修改FresnelShader。fragmentShader中的后记添加一行:
vec4 color = vec4( colorR, colorG, colorB, 1); // colorR,G,B those are floats passed to the shader
通过修改这一行:
gl_FragColor = mix( color, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );
您可以只添加折射的颜色。