refract¶
-
taichi_glsl.vector.
refract
(I, N, eta)¶ Calculate the refraction direction for an incident vector.
For a given incident vector I, surface normal N and ratio of indices of refraction, eta, refract returns the refraction vector, R.
- Parameters
I – Specifies the incident vector.
N – Specifies the normal vector.
eta – Specifies the ratio of indices of refraction.
- Returns
The return value is calculated as:
k = 1 - eta * eta * (1 - dot(N, I) * dot(N, I)) R = I * 0 if k >= 0: R = eta * I - (eta * dot(N, I) + sqrt(k)) * N return R
- Note
The input parameters I and N should be normalized in order to achieve the desired result.
- See also