|
|
Paris scripsit::
> I am currently writing a physically-based rendering engine. I need to
> deviate 3-Dimensional vectors in a random "cone" whose principle axis is
> equal to the vector itself. The size of the "cone" is pregiven in
> steradians.
>
> I understand that povray uses a lookup table to get directions for radiosity
> samples. I do not have this option.
>
> My current method uses orthogonal basis vectors in the following way:
>
> [1] First produce a random unit vector that deviates randomly from the
> positive y axis <0,1,0> by some given steradians, r. This part is easy
> and I have already solved it.
>
May I ask how is your distribution on the projection disc ? (at
least, at the specification level ?)
Is it uniform in density (deviation to <0,0.5> has same probability
than deviation to <0,1>, in cartesian coordinate) ?
Or is uniform in direction distribution with uniform deviation on
the radius (using polar coordinate, independantly) ?
Note that both appraoches are not identical in result.
Or yet another method ?
Have a look at
http://mathworld.wolfram.com/SpherePointPicking.html
and
http://mathworld.wolfram.com/DiskPointPicking.html
> [2] Next I produce unit orthogonal basis vectors around a given surface
> normal N, such that the "up" vector is equal to N, and the other two are
> both orthogonal to N.
>
There come your problem!
You have a freedom which must be removed by your code... hence your
banding!
Remember that a sphere cannot have combed hairs!
Your method will always have at least one singularity.
> [3] I then project the random vector from [1] into the "axis system" in [2].
I would have rotated [y] to match [N] but that the same thing.
> Does anyone know a different method for randomly deviating a vector from its
> original direction into a new one such that the random vector remains within
> a given cone of r steradians????
Depend on your density of distribution along the cone axis...
Brute force is always an option: generate a random unit vector using
three random (cartesian coordinates, trap the bogus <0,0,0>, adjust
length after processing), check if it is in the cone, if not do it
again... Do not rotate/play with it, just use as is.
Oh, yes, use three seeds, not a single one for everythings !
(unless you check the random generator for non-correlation in 3D)
To check the cone thing, a simple scalar product of the two vector
should be enough, you just have to precompute the solid angle once
to the right value (as it involves computing portion of a sphere, it
might involve some heavy computation: solving
A = 2 pi h , the surface of a portion of unit sphere of width h,
then computing the radius of the projected disc...)
Other distribution might be different.
>
> Ideally, your answer will not involve the use of sin() and cos(), for the
> obvious reasons.
--
Eifersucht ist die Leidenschaft, die mit Eifer sucht, was Leiden
schafft.
Eco: -8.75 Soc: -6.72
http://www.politicalcompass.org/
Post a reply to this message
|
|