refract

> # NAME

> refract - computes a refraction vector.

> # SYNOPSIS

>       fixed3 refract(fixed3 i, fixed3 n, fixed eta);
>       half3  refract(half3  i, half3  n, half  eta);
>       float3 refract(float3 i, float3 n, float eta);

> # PARAMETERS

> i

>   Incidence vector.

> n

>   Normal vector.

> eta

>   Ratio of indices of refraction at the surface interface.

> # DESCRIPTION

> Returns a refraction vector given an incidence vector, a normal vector for a surface, and a ratio of indices of refraction at the surface's interface.

> The incidence vector i and normal vector n should be normalized.

> # REFERENCE IMPLEMENTATION

> reflect for float3 vectors could be implemented this way:

>       float3 refract( float3 i, float3 n, float eta )
>       {
>         float cosi = dot(-i, n);
>         float cost2 = 1.0f - eta * eta * (1.0f - cosi*cosi);
>         float3 t = eta*i + ((eta*cosi - sqrt(abs(cost2))) * n);
>         return t * (float3)(cost2 > 0);
>       }

> # PROFILE SUPPORT

> refract is supported in all profiles.

> Support in the fp20 is limited.

> # SEE ALSO

> abs, cos, dot, reflect, sqrt