======================================================= !Refracts a viewing vector V at a normal N using the relative * refraction index eta. Eta is refraction index of outside medium * (where N points into) divided by refraction index of the inside * medium. The vectors V and N have to point towards the same side * of the surface. The cosine between V and N is given as input and * the c
| 32 | * of the surface. The cosine between V and N is given as input and |
| 33 | * the cosine of -N and transmission ray is computed as output. */ |
| 34 | inline Sample3f refract(const Vec3fa& V, const Vec3fa& N, const float eta, |
| 35 | const float cosi, float &cost) |
| 36 | { |
| 37 | const float k = 1.0f-eta*eta*(1.0f-cosi*cosi); |
| 38 | if (k < 0.0f) { cost = 0.0f; return make_Sample3f(Vec3fa(0.f),0.0f); } |
| 39 | cost = sqrt(k); |
| 40 | return make_Sample3f(eta*(cosi*N-V)-cost*N, sqr(eta)); |
| 41 | } |
| 42 | |
| 43 | /*! Computes fresnel coefficient for media interface with relative |
| 44 | * refraction index eta. Eta is the outside refraction index |
no test coverage detected