Advertisement

Direction Randomization and Box-polynomial intersection

Started by February 16, 2003 02:44 PM
5 comments, last by LinaInverse2010 22 years ago
I''m trying to get diffuse reflection working in my ray tracer, but I''m not sure how to randomize the reflection vector. I know that you need two random numbers. One for the rotated direciton around the normal, and the other with respect to the surface. I don''t know how to do this with keeping it close to the origonal direction, while keeping it somewhat random. I think it involves a Cos with the random variable, but I can''t seem to get it right. Also, I''m looking for an algorithm to intersect a box with an arbitrary polynomial (with respect to x,y,z which are paramterized by t, ex. x = x0 + dx*t) in 3d space. Basically I''m trying to make a box for a row of pixels and see what objects intersect that box. LinaInverse2010

bump for a worthy post (wish I could help, but my math is not that high level :-p).

~SPH
AIM ME: aGaBoOgAmOnGeR
Advertisement
If I remember correctly for a diffuse surface, the reflected angles are acos(sqrt(u)) for the angle w.r.t. the normal (where u is a uniformly distributed random variable in [0,1]), and then the other angle should be uniformly distributed.

Its explained in henrik wann jensens book, which is a good introduction to GI, you might be able to find it in one of his other papers (http://graphics.ucsd.edu/~henrik/) or in any introduction to monte carlo raytracing.

"Math is hard" -Barbie
"Math is hard" -Barbie
Ok, I understand that part, and I understand what is in Jensen''s book, but I don''t understand how to actually impliment it efficiently.

Heres what I have to work with:
Incoming Ray : i
Normal : n
Theta (angle from normal of outgoing ray) : theta
Phi (angle rotated around normal: phi

where I can calculate (Eps1, Eps2 random variables [0,1]):
theta = cos^-1(sqrt(Eps1))
phi = 2*pi*Eps2

Heres what I need:
Outgoing Ray (reflected) : o

Where
n dot o = theta
And I''m not sure how phi fits in as an equation.

But knowing n and theta (ignoring phi) how do I solve for o?

LinaInverse2010
Sorry, I just realized what I posted before was wrong, that was for a diffuse component of a surface.

In Jensen''s book, I found the a description of Schlick''s BRDF with glossy reflection, but I want a model for just slightly randomizing the direction of the vector.

Even reading through his book, I still don''t completely understand how to randomize this direction. Do I have to use another model other than the Phong model to get diffuse reflection?

LinaInverse2010
Jensen only gives the importance sampling function for the schlick model, not for the phong model, presumably because it''s a lot simpler. I''m not sure whether it is easy to derive one for phong, or whether you have the mathematical background to do it (I certainly don''t). You''re probably better off going with the schlick model.

"Math is hard" -Barbie
"Math is hard" -Barbie
Advertisement
Ok thanks anyways, By the way can anybody answer my second question about a box polynomial intersection??

LinaInverse2010

This topic is closed to new replies.

Advertisement