three
Version:
JavaScript 3D library
38 lines (20 loc) • 647 B
JavaScript
export default /* glsl */`
vWorldPosition = worldPosition.xyz;
vec3 cameraToVertex;
if ( isOrthographic ) {
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
}
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
vReflect = reflect( cameraToVertex, worldNormal );
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
`;