three
Version:
JavaScript 3D library
63 lines (33 loc) • 1.26 kB
JavaScript
export default /* glsl */`
vec3 cameraToFrag;
if ( isOrthographic ) {
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToFrag = normalize( vWorldPosition - cameraPosition );
}
// Transforming Normal Vectors with the Inverse Transformation
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
vec3 reflectVec = vReflect;
vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
vec4 envColor = vec4( 0.0 );
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
outgoingLight += envColor.xyz * specularStrength * reflectivity;
`;