我曾试图手工实现它,但最终我在 GLSL 中找到了文档中描述为
refract
的函数,这在 GLSL 1.1 中是这样的://For a given incident vector I, surface normal N and ratio of
//indices of refraction, eta, refract returns the refraction vector, R.
//R is calculated as:
k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I));
if (k < 0.0)
R = genType(0.0); // or genDType(0.0)
else
R = eta * I - (eta * dot(N, I) + sqrt(k)) * N;
//The input parameters I and N should be normalized in order to
//achieve the desired result.
我想知道这些方程是从哪里来的。我在互联网和我拥有的书籍(Real Time Rendering圣经或Phisically Based Rendering最新版)中搜索,它们都引用了这个实现,但没有解释,或者只是给出了答案。
尝试使用几何图形手动计算会得到其他答案,但显然这对于像GLSL这样常见的函数来说是很费力的。所以我更喜欢使用这种优化表示法。
我只有这个:
a.b = |a||b|cos(angle) (Dot product)
angleOut = eta * sin(angleIn) (Snell's Law).
你知道这来自哪里吗?有没有任何文档或参考可以阅读?