蒙特卡罗路径追踪算法这部分的目的是什么?

发布于 2024-12-19 16:40:47 字数 878 浏览 5 评论 0原文

在使用大量蒙特卡罗样本进行路径追踪的所有简单算法中,算法的追踪路径部分会随机选择返回当前表面的发射值和继续追踪来自该表面半球的另一条光线(例如在幻灯片此处)。就像这样:

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’)
  1. 这只是使用俄罗斯轮盘赌来终止路径同时保持公正的一种方式吗?当然,将所有光线路径的发射和反射属性一起计算并使用俄罗斯轮盘赌来决定是否继续跟踪会更有意义。

  2. 这里有一个后续问题:为什么我看到的一些算法(例如《基于物理的渲染技术》一书中)只计算发射一次,而不是考虑对象上的所有发射属性?渲染方程基本上是

    L_o = L_e + (光线从其他表面射入该表面的半球)

    这似乎计算了这个 L_o 和所有其他 L_o 的积分中的发射属性,因此算法应该遵循。

In all of the simple algorithms for path tracing using lots of monte carlo samples the tracing the path part of the algorithm randomly chooses between returning with the emitted value for the current surface and continuing by tracing another ray from that surface's hemisphere (for example in the slides here). Like so:

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’)
  1. Is this just a way of using russian roulette to terminate a path while remaining unbiased? Surely it would make more sense to count the emissive and reflective properties for all ray paths together and use russian roulette just to decide whether to continue tracing or not.

  2. And here's a follow up question: why do some of these algorithms I'm seeing (like in the book 'Physically Based Rendering Techniques') only compute emission once, instead of taking in to account all the emissive properties on an object? The rendering equation is basically

    L_o = L_e + integral of (light exiting other surfaces in to the hemisphere of this surface)

    which seems like it counts the emissive properties in both this L_o and the integral of all the other L_o's, so the algorithms should follow.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

紫﹏色ふ单纯 2024-12-26 16:40:47

实际上,单次发射与反射的计算有点过于简单。为了回答第一个问题,抛硬币用于终止光线,但它会导致更大的偏差。第二个问题有点复杂......

Shirley 的摘要中, Wang 和 Zimmerman TOG 94,作者简要总结了蒙特卡罗采样的好处和复杂性:

在分布光线追踪器中,直接照明的关键部分
计算是阴影射线测试的采样策略。蒙特
使用卡罗积分和重要性采样来执行此操作
计算。重要性抽样涉及设计
特定于被积函数的概率密度函数,用于
生成数值求积的样本点。可能性
密度函数的提出有助于直接照明
根据各种简单形状的灯具进行计算。一种方法用于
定义一组灯具的概率密度函数是
提出允许进行直接照明计算
无论灯具数量有多少,都可以用一个样品来完成。

如果我们开始剖析这个抽象概念,以下是一些要点:

  1. 灯不是点:在现实生活中,我们几乎从不处理点光源(例如,单个 LED)。
  2. 阴影通常很柔和:这是非点光源的结果。在现实生活中很少见到真正棱角分明的影子。
  3. 噪声(尤其是明亮的采样伪影)会过度分散注意力:人类对事物的外观有很多直觉。请查看 OP 链接演示文稿中的幻灯片 5(桌子上的玻璃球)。注意阴影中的亮点。

当渲染以获得更真实的视觉效果时,必须根据表面的 双向反射率分布函数

请注意,这是一种引导采样方法,与原始问题的“随机方向生成射线”方法明显不同,因为它具有:

  1. 更准确:链接 PDF 中的图像会受到 PDF 处理的影响。图 10 是原始演示文稿的合理表示 - 请注意,您有时会看到缺乏明亮斑点伪像(如原始演示文稿的图 5 所示)。

  2. 速度明显加快:正如原始演示文稿所述,无引导蒙特卡罗采样可能需要相当长的时间才能收敛。更多采样光线 = 更多计算 = 更多时间。

In reality, the single emission vs. reflection calculation is a bit too simplistic. To answer the first question, the coin-flip is used to terminate the ray but it leads to much greater biases. The second question is a bit more complex....

In the abstract of Shirley, Wang and Zimmerman TOG 94, the authors briefly summarize the benefits and complexities of Monte Carlo sampling:

In a distribution ray tracer, the crucial part of the direct lighting
calculation is the sampling strategy for shadow ray testing. Monte
Carlo integration with importance sampling is used to carry out this
calculation. Importance sampling involves the design of
integrand-specific probability density functions which are used to
generate sample points for the numerical quadrature. Probability
density functions are presented that aid in the direct lighting
calculation from luminaires of various simple shapes. A method for
defining a probability density function over a set of luminaires is
presented that allows the direct lighting calculation to be carried
out with one sample, regardless of the number of luminaires.

If we start dissecting that abstract, here are some of the important points:

  1. Lights aren't points: in real life, we're almost never dealing with a point light source (e.g., a single LED).
  2. Shadows are usually soft: this is a consequence of the non-point lights. It's very rare to see a truly hard-edged shadow in real life.
  3. Noise (especially bright sampling artifacts) are disproportionately distracting: humans have a lot of intuition about how things should look. Look at slide 5 (the glass sphere on a table) in the OP's linked presentation. Note the bright specks in the shadow.

When rendering for more visual realism, both of the sets of reflected visibility rays and lighting calculation rays must be sampled and weighted according to the surface's bidirectional reflectance distribution function.

Note that this is a guided sampling method that's distinctly different from the original question's "generate ray in random direction" method in that it is both:

  1. More accurate: the images in the linked PDF suffer a bit from the PDF process. Figure 10 is a reasonable representation of the original - note that lack of bright speckle artifacts that you will sometimes see (as in figure 5 of the original presentation).

  2. Significantly faster: as the original presentation notes, unguided Monte Carlo sampling can take quite a while to converge. More sampling rays = much more computation = more time.

夏天碎花小短裙 2024-12-26 16:40:47

阅读幻灯片后(感谢您的发帖),我将尽力修改我的答案。

  1. 这只是使用俄罗斯轮盘赌终止路径的一种方法吗
    同时保持公正?当然,计算起来更有意义
    所有光线路径的发射和反射属性一起
    并使用俄罗斯轮盘赌来决定是否继续追踪
    或不。

也许发射和反射属性的处理方式不同,因为反射路径依赖于入射路径,而发射路径则不然(至少对于光谱表面而言)。该算法是否采用贝叶斯方法并使用有关入射角的先验信息作为预测反射角的先验信息?或者这是对所有路径进行费曼积分以得出概率?如果不深入研究该理论的细节,很难说清楚。

我之前对黑体的评论是非常不正确的。我看到幻灯片讨论了(R、G、B)组件;黑体发射率在所有波长上积分。

  1. 这是一个后续问题:为什么我要使用其中一些算法
    看到(就像在“基于物理的渲染技术”一书中)
    只计算一次发射,而不是考虑所有
    物体的发射特性?渲染方程为
    基本上

    L_o = L_e + (从其他表面射出的光进入
    这个表面的半球)

表面的单一发射率将假设波长或方向上不存在函数关系。我不知道它对于渲染逼真的图像有多大意义。

发布的内容肯定令人印象深刻。我想知道如果将您想到的复杂性包括在内,它们看起来会有何不同?

感谢您提出一个好问题 - 我正在投票。我已经很久没有思考过这样的问题了。我希望我能提供更多帮助。

After reading the slides (thank you for posting), I'll amend my answer as best I can.

  1. Is this just a way of using russian roulette to terminate a path
    while remaining unbiased? Surely it would make more sense to count
    the emissive and reflective properties for all ray paths together
    and use russian roulette just to decide whether to continue tracing
    or not.

Perhaps the emitted and reflected properties are treated differently because the reflected path depends on the incident path in a way that emitted paths do not (at least for a spectral surface). Does the algorithm take a Bayesian approach and use prior information about the incidence angle as a prior for predicting the reflective angle? Or is this a Feynman integration over all paths to come up with a probability? It's hard to tell without digging deeper into the details of the theory.

My earlier black body comment is quite incorrect. I see that the slides talk about (R, G, B) components; black body emissivities are integrated over all wavelengths.

  1. And here's a follow up question: why do some of these algorithms I'm
    seeing (like in the book 'Physically Based Rendering Techniques')
    only compute emission once, instead of taking in to account all the
    emissive properties on an object? The rendering equation is
    basically

    L_o = L_e + integral of (light exiting other surfaces in to the
    hemisphere of this surface)

A single emissivity for the surface would assume that there's no functional relationship on wavelength or direction. I don't know how significant it is for rendering photo-realistic images.

The ones that are posted are certainly impressive. I wonder how different they would look if the complexities that you have in mind were included?

Thank you for posting a nice question - I'm voting it up. It's been a long time since I've thought about this kind of problem. I wish I could be more helpful.

琉璃繁缕 2024-12-26 16:40:47
  1. 是的,这是俄罗斯轮盘赌的一个非常基本的实现,尽管通常终止的概率会考虑光强度(即较少的光意味着该值对最终总和的贡献较小,因此使用较高的终止概率)。
  1. Yes that is a very basic implementation of Russian Roulette, though normally the probability of terminating would take into account the light intensity (i.e. less light means the value contributes less to the final summation so use a higher probability of terminating).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文