0

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)

Seb
  • 3,655
  • 3
  • 17
  • 17

1 Answers1

1

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.

Dade916
  • 305
  • 1
  • 4
  • I think you're correct. I have been thinking along those lines but can't quite formulate it. What do you mean by "sample result". Do you know other methods? like acceptance-rejection? As far as I understand these are used to draw samples from a distribution. In my case I am able to do that. I now need to "map" those samples to the hemisphere above the point - That's what I am struggling with. – Seb Jun 14 '13 at 10:58
  • 1
    By "sample result", I mean, for instance, the radiance incoming along the sampled direction. It depends on exactly what you are sampling. If you haven't already, I suggest you to buy and read http://www.pbrt.org book. It is a classic text where all this kind of problems are faced and explained. – Dade916 Jun 15 '13 at 14:25