refract VEX function

Returns the refraction ray given an incoming direction, the normalized normal and an index of refraction.

Contexts: image3d, chop, cop, pop, sop, surface, displace, fog, light, shadow, photon, cvex

See also: fresnel

  1. vector refract(vector direction, vector normal, float index)

Returns the refraction ray given an incoming direction, the normalized normal and an index of refraction.

The index is a relative index of refraction, the ratio between the interior and exterior index of refraction, where the exterior is defined by the direction of the normals (normals point away from the interior).

In the case of total internal reflection, this function returns the reflection vector.

For example:

refract(normalize(I), normalize(N), outside_to_inside_ior)