在使用大量蒙特卡罗样本进行路径追踪的所有简单算法中,跟踪算法的路径部分随机选择返回当前表面的发射值并继续追踪来自该表面半球的另一条射线(例如,这里滑动 ).像这样:
TracePath(p, d) returns (r,g,b) [and calls itself recursively]:
Trace ray (p, d) to find nearest intersection p’
Select with probability (say) 50%:
Emitted:
return 2 * (Le_red, Le_green, Le_blue) // 2 = 1/(50%)
Reflected:
generate ray in random direction d’
return 2 * fr(d ->d’) * (n dot d’) * TracePath(p’, d’)
Run Code Online (Sandbox Code Playgroud)
这只是一种使用俄罗斯轮盘赌终止路径同时保持不偏不倚的方式吗?当然,将所有射线路径的发射和反射特性统计在一起并使用俄罗斯轮盘只是为了决定是否继续跟踪更有意义.
这是一个后续问题:为什么我所看到的这些算法中的一些(如"基于物理的渲染技术"一书)只计算一次发射,而不是考虑对象的所有发射属性?渲染方程基本上是
L_o = L_e + integral of (light exiting other surfaces in to the hemisphere of this surface)
这似乎计算了这个L_o和所有其他L_o的积分中的自发属性,所以算法应该遵循.