光线追踪光泽反射:采样光线方向

Fab*_*oni 1 raytracing

我正在为 iPad 编写光线追踪器。现在我正在尝试为对象添加光泽反射。我该如何实施?我在网上阅读了一些文档:

http://www.cs.cmu.edu/afs/cs/academic/class/15462-s09/www/lec/13/lec13.pdf http://www.cs.cornell.edu/courses/cs4620/2012fa /讲座/37raytracing.pdf

如果我理解正确而不是像标准反射那样跟踪单条光线,我必须在随机方向上跟踪 n 条光线。我如何为每条射线获得这个随机方向?我如何生成这些样本?

Dan*_*son 5

  • 镜面反射是指入射方向与表面法线之间的夹角等于出射方向与表面法线之间的夹角。
  • 漫反射意味着出射方向的角度随机且均匀地分布在表面法线的半球上。
  • 您可以将光泽反射视为这两个极端之间的光谱,其中该光谱上的位置(或光泽量)由范围从 0 到 1 的“光泽度”因子定义。
  • 对于漫反射或光泽反射,您需要能够从可能的反射方向的分布中随机生成一条光线,然后跟随它。
  • 然后,取许多样本并平均结果。
  • 因此,对于光泽反射,关键是反射光线的分布以镜面方向为中心。光线分布越宽,光泽越扩散。 一个例子

我将首先按顺序编写以下辅助方法:

// get a random point on the surface of a unit sphere
public Vector getRandomPointOnUnitSphere(); 

// get a Ray (with origin and direction) that points towards a 
// random location on the unit hemisphere defined by the given normal
public Ray getRandomRayInHemisphere(Normal n); 

// you probably already have something like this
public Ray getSpecularReflectedRayInHemisphere(Normal n, Ray incomingRay);

// get a Ray whose direction is perturbed by a random amount (up to the
// glossiness factor) from the specular reflection direction
public Ray getGlossyReflectedRayInHemisphere(Normal n, Ray incomingRay, double glossiness);
Run Code Online (Sandbox Code Playgroud)

一旦你开始工作,你可能希望根据实际的 BRDF 对象重新设计你的实现,如果你想扩展你的跟踪器来支持折射,这将在一定程度上组织逻辑并帮助你。