dar*_*aze 9 math geometry raytracing glsl
我正在尝试调试我的简单光线跟踪器,模拟来自穿过镜头的一个点的光线.我只需要折射效果.
我试图手工完成,但最后我refract
从GLSL中找到了,这在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.
Run Code Online (Sandbox Code Playgroud)
我想知道这些方程式来自哪里.我搜索了互联网和我拥有的书籍(实时渲染圣经,或者基于Phisically Based Rendering的最后编辑.)所有这些都参考了这个实现,没有解释,或只是告诉解决方案.
尝试从开始使用几何形状手工完成它带来了我的其他答案,但显然只是一个非常常见的功能,如GLSL的艰苦工作.所以我更喜欢使用这种优化的符号.
我只有这个:
a.b = |a||b|cos(angle) (Dot product)
angleOut = eta * sin(angleIn) (Snell's Law).
Run Code Online (Sandbox Code Playgroud)
你知道它来自哪里吗?阅读的任何文件或参考?
您可以在本书的第16.5节中找到解释:
FOLEY,James D.(编辑).计算机图形学:原理与实践,C语言第二版.Addison-Wesley Professional,1996.
这些是相关页面,它们来自Google图书搜索(参见2013-12-29T10:15:00 + 01:00):
参考[HECK84]是
HECKBERT,Paul S.; HANRAHAN,Pat.光束跟踪多边形对象.在:ACM SIGGRAPH计算机图形学.ACM,1984.p.119-127.
并有一个标题为"反射和折射变换"的详细附录.