|
|
Hello all,
I'm a bit confused about the following code snippet, found in
radiosit.cpp, starting at line 779 in ra_gather():
Begin code paste
--------------------------------------------------------------------
if ( fabs(LayNormal[Z] - 1.) < .001 ) /* pretty well
straight Z, folks */
{
/* we are within 1/20 degree of pointing in the Z axis. */
/* use all vectors as is--they're precomputed this way */
Assign_Vector(direction, random_vec);
}
else
{
#ifdef RAD_SAMPLES_RANDOMIZE_PATCH /* Christoph Hormann January 2003 */
direction[X] = n2[X]*(random_vec[X]*RCos + random_vec[Y]*RSin)
+ n3[X]*(random_vec[Y]*RCos - random_vec[X]*RSin) +
LayNormal[X]*random_vec[Z];
direction[Y] = n2[Y]*(random_vec[X]*RCos + random_vec[Y]*RSin)
+ n3[Y]*(random_vec[Y]*RCos - random_vec[X]*RSin) +
LayNormal[Y]*random_vec[Z];
direction[Z] = n2[Z]*(random_vec[X]*RCos + random_vec[Y]*RSin)
+ n3[Z]*(random_vec[Y]*RCos - random_vec[X]*RSin) +
LayNormal[Z]*random_vec[Z];
#else
direction[X] = n2[X]*random_vec[X] + n3[X]*random_vec[Y] +
LayNormal[X]*random_vec[Z];
direction[Y] = n2[Y]*random_vec[X] + n3[Y]*random_vec[Y] +
LayNormal[Y]*random_vec[Z];
direction[Z] = n2[Z]*random_vec[X] + n3[Z]*random_vec[Y] +
LayNormal[Z]*random_vec[Z];
#endif
}
--------------------------------------------------
End code paste
Disregarding the RAD_SAMPLES_RANDOMIZE_PATCH for a moment, I understand
the following: We are in the function that shoots gather rays for a
point that needs indirect illumination calculated for it. If the Layer
normal of the point in question is very close to being parallel with the
World's Z axis, then the sample direction is used as-is, otherwise it is
adjusted to compensate for the direction of the normal.
What I see the RAD_SAMPLES_RANDOMIZE_PATCH is doing is that, along with
adjusting for the Layer normal's Z direction, it gives the sample
direction a random rotation about the Z axis.
However, I notice that if the Layer normal is parallel to the World's Z
axis, no random rotation is done. I don't understand why the random
rotation isn't done in all cases. It seems that if the Layer normal
happens to be almost parallel to the World Z axis, then no random
rotation is done at all, despite the user having "randomize on" in their
global settings.
Thus, it appears that certain areas of a scene that uses "randomize on"
may not have their sample directions randomly rotated while others
areas will, depending on the direction of their surface normal. Is my
analysis correct?
Thanks,
George
--
-------------------------
George Pantazopoulos
http://www.gammaburst.net
Post a reply to this message
|
|