问题
I'm not a shader specialist, but I'd like to pass the color value to the shader that could maybe blended with the env map color.
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;
I'm clueless. Thanks for any suggestions.
回答1:
For the futures ones ;) You need to modify the FresnelShader firstly by passing the color to the shader. Afterwords in the fragmentShader add a line:
vec4 color = vec4( colorR, colorG, colorB, 1); // colorR,G,B those are floats passed to the shader
and by modifing this line:
gl_FragColor = mix( color, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );
You can addjust the refracted color.
来源:https://stackoverflow.com/questions/18046248/three-js-fresnel-shader-color-changing-or-env-map-blending