scott wrote:
>> Another way is to generate a random vector:
>>
>> #local vResult=vrotate(x,<rand(Seed),rand(Seed),rand(Seed)>*360);
>
> vResult is not uniformly distributed over the sphere with this approach
> though...
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?
Post a reply to this message
|