PDA

View Full Version : Robust stencil shadow volumes



jonasmr
01-23-2004, 04:12 AM
Hi.

I'm working with the robust stencil shadows volumes, as presented in the 2002 siggraph article, and Eric Lengyel column from gamasutra, but there seems to be some things i have a hard time understanding, with regards to the projection matrix with backclipping plane at infinity.


First of, they do a homogenous vector difference - What is this?
I would say it should be X_1/W_1 - X_2/W_2, but somehow, they rearrange it to be X_1*W_2-X_2*W_1.

I can clearly see that it just works(tm), and that my arithmethic will fail for lights/points at infinity. What is the explanation, how is it rewritten? How do I intuitively understand it?

The second thing is with regards to the matrix. Given the vector difference, I see no reason why we should not end up with a point projected to infinity, looking like this

[ x y 0 0 ]

in case the light and the vertex have the same z value. This leaves me wondering what will happend in the clip stage.

Clearly the only value that will satisfy
-w <= (x,y,z) <= w, is zero. The z value is fine, but what happends to x and y? Will the clipping clip them to zero?

Can this really be what is happening?

Any hints appreciated, I'm going to refresh those line clipping algorithms to try and understand what happends.

jonasmr
01-23-2004, 06:00 AM
Regarding the second question, I think I have an clearer understanding now.

The thing is, that it is the line segment with _one_ of the vertices with a zero W value. When this is clipped against the planes x=w, x=-w etc., in homogenous coordinates, it will get a valid(nonzero) value that we can divide with.

My first question is still unclear to me http://www.opengl.org/discussion_boards/ubb/smile.gif

cass
01-23-2004, 08:12 AM
Hi jonasmr,

On your first question, multiplying all components of a homogeneous point by a constant doesn't change the projected real point, so

w1*w2*( x1/w1 - x2/w2) = (x1*w2 - x2*w1).

And this way, we don't have to worry about divide-by-zero.

Make sense?

Thanks -
Cass

edit: I should proofread before I submit.

[This message has been edited by cass (edited 01-23-2004).]

jonasmr
01-23-2004, 01:36 PM
Cass -

Yes, that is quite clear now.

Pretty simple, and very neat.

Thank you,

Jonas