MCPcopy Create free account
hub / github.com/RenderKit/embree / refract

Function refract

tutorials/common/tutorial/optics.h:34–41  ·  view source on GitHub ↗

======================================================= !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

Source from the content-addressed store, hash-verified

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. */
34inline 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

Calls 4

make_Sample3fFunction · 0.85
Vec3faClass · 0.50
sqrtFunction · 0.50
sqrFunction · 0.50

Tested by

no test coverage detected