使用任意分布对半球进行抽样 [英] Sampling a hemisphere using an arbitary distribtuion

查看:578
本文介绍了使用任意分布对半球进行抽样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个射线追踪器,并且我希望根据某种分布从点 p 将光线射入该点之上的半球。
$ b $ 1)我推导出了一种方法,可以在 p 图片

phi = 2 * pi * X_1



alpha = arccos(1-(1-cosθ)* X_2) $ b $ p
$ x $ sin $($)
code> y = sin(alpha)* sin * phi


z = -cos(alpha)



其中 X 是一个统一的随机数



这很有用,我对此很满意。但是我的问题是如果我不想要一个统一的分配会发生什么。



我已经使用了来自这里,我可以从分段任意分布中抽取样本。然而,如果我只是说:

code> alpha = arccos(1-(1-cos(theta))B1)

其中 B 是一个从阿尔比特分布生成的随机数。
它表现不好...我做错了什么?提前致谢。我真的很需要这方面的帮助。



其他:
也许我在问一个主要问题。退一步:
是否有一种方法根据任意分布在半球上生成点。我有一个均匀采样半球的方法,一个用于余弦加权半球采样的方法。 (第663-669页 pbrt.org

解决方案

使用均匀分布,您可以对样本结果进行平均并获得正确的结果。这相当于将每个样本结果除以样本概率密度函数(PDF),并且在均匀分布的情况下,它仅为1 / sample_count(即平均结果相同)。

使用任意分布,您仍然可以将样本结果除以示例PDF,但PDF现在取决于您正在使用的任意分布。我假设你的错误在这里。


I am writing a ray tracer and I wish to fire rays from a point p into a hemisphere above that point according to some distribution.

1) I have derived a method to uniformly sample within a solid angle (defined by theta) above p Image

phi = 2*pi*X_1

alpha = arccos (1-(1-cos(theta))*X_2)

x = sin(alpha)*cos(phi)

y = sin(alpha)*sin*phi

z = -cos(alpha)

Where X is a uniform random number

That works and Im pretty happy with that. But my question is what happens if I do not want a uniform distribution.

I have used the algorithm on page 27 from here and I can draw samples from a piecewise arbitrary distribution. However if I simply say:

alpha = arccos (1-(1-cos(theta)) B1)

Where B is a random number generated from an arbiatry distribution. It doesn't behave nicely...What am I doing wrong? Thanks in advance. I really really need help on this

Additional: Perhaps I am asking a leading question. Taking a step back: Is there a way to generate points on a hemisphere according to an arbitrary distribution. I have a method for uniformly sampling a hemisphere and one for cosine-weighted hemisphere sampling. (pg 663-669 pbrt.org)

解决方案

With an uniform distribution, you can just average the sample results and obtain the correct result. This is equivalent to divide each sample result by the sample Probability Density Function (PDF) and, in the case of an uniform distribution, it is just 1 / sample_count (i.e. the same of averaging the results).

With an arbitrary distribution, you have still to divide the sample result by the sample PDF however the PDF now depends on the arbitrary distribution you are using. I assume your error is here.

这篇关于使用任意分布对半球进行抽样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆