POV-Ray : Newsgroups : povray.programming : Randomly deviated vector : Randomly deviated vector Server Time
18 May 2024 03:26:12 EDT (-0400)
  Randomly deviated vector  
From: Paris
Date: 25 Oct 2006 19:10:01
Message: <web.453fedef87fb35ab5dbe37df0@news.povray.org>
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.

[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.

[3] I then project the random vector from [1] into the "axis system" in [2].

One would think this algorithm works perfectly.  IT DOES NOT. It produces
banding artifacts right along the parts of the surfaces where the largest
component of the surface Normal changes from one to the next.  Let me give
an example:  Imagine the surface normals on a cylinder morphing smoothly
from <0.6,0,0.7> to <0.7,0,0.6>   Somewhere along the surface, the x
component overtakes the z component of the vector. This causes an
instantaneous switch in the orthogonal basis vectors from part [2].
"Right" changes to "-Right" and so forth.   Random processes along this
boundary go into a little "minishift" that shows up in the rendered image
as an anomaly along the surface.

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????

Ideally, your answer will not involve the use of sin() and cos(), for the
obvious reasons.

Thank you for your help.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.