|
|
> I use this:
>
> y = sqrt(rand(0..1))
> theta = acos(y)
> phi = 2*PI*rand(0..1)
>
> x = sin(theta)*cos(phi)
> z = sin(theta)*sin(phi)
>
> What I don't get is the sqrt(rand()). Why sqrt? Why not just rnd()? Does
> the sqrt give us the cosine distribution and should remove the need to
> later scale by taking cosine of the angle between normal and the light
> ray?
No, you are simply choosing a fixed Y position, which then defines a ring
around the sphere of possible points. Then phi is used to choose a point at
random on this ring which gives you the final point.
The reason for using sqrt for y is because you want points equally
distributed over the surface of the sphere, not between y=0 to 1. You can
visualise this by drawing a straight line alongside a circle. If you
distribute points evenly on the line, then trace them across to the circle,
they won't be distributed evenly on the circle. The sqrt fixes that.
Post a reply to this message
|
|