Oliver LS

12-12-2002, 09:01 PM

I have been studying the nvidia papers and code on robust infinite shadow volumes using zfail stencil. The stencil isn't quite the issue yet, there are a couple of things here that have gotten me a bit lost. I would appreciate any input on this.

In this example code, for the drawing of the caps and the poss shil edges, they begin by doing this:

vec4f olight;

matrix4f ml = object[mindex].get_inverse_transform() * light.get_transform();

ml.mult_matrix_vec(light_position, olight);

This 'object' and 'light' seem to be of strange types, and I can't quite track down what they are doing in these .get_*_transform() calls. I understand of course object is the shadowcasting mesh, and light is the light source. As best as I can understand now, they are just getting the matricies used to transform these objects into world coordinates? This does not seem right though, as the next line is to multiply that by (what i assume) the light's position? What they are doing here is obviously key to the ideas, as their drawing looks like such:

if(facing_light) // draw locally

glVertex4f(pn.x, pn.y, pn.z, 1);

else // draw at infinity

glVertex4f(pn.x*olight[3] - olight[0],

pn.y*olight[3] - olight[1],

pn.z*olight[3] - olight[2],

0);

So the real question is, what is olight, how and why is this derived, and why is it required to draw these caps at infinity?

The second question I have is strongly related, the way I understand the vertex4f(x,y,z,w) calls, it works out as x/w y/w z/w. How is division by zero allowed? I am not familiar with this at all, my only intuition says that opengl somehow works this out as a limit; but that leads me to believe that these verticies would be interpreted as +/- INF, which does not make sense with how these caps are drawn.

I appreciate in advance any time somebody could spend explaining this, and I apologize for posting this in the advanced forum; but I had serious doubts that I would receive much help with this topic in the newbie one.

.oliver.

In this example code, for the drawing of the caps and the poss shil edges, they begin by doing this:

vec4f olight;

matrix4f ml = object[mindex].get_inverse_transform() * light.get_transform();

ml.mult_matrix_vec(light_position, olight);

This 'object' and 'light' seem to be of strange types, and I can't quite track down what they are doing in these .get_*_transform() calls. I understand of course object is the shadowcasting mesh, and light is the light source. As best as I can understand now, they are just getting the matricies used to transform these objects into world coordinates? This does not seem right though, as the next line is to multiply that by (what i assume) the light's position? What they are doing here is obviously key to the ideas, as their drawing looks like such:

if(facing_light) // draw locally

glVertex4f(pn.x, pn.y, pn.z, 1);

else // draw at infinity

glVertex4f(pn.x*olight[3] - olight[0],

pn.y*olight[3] - olight[1],

pn.z*olight[3] - olight[2],

0);

So the real question is, what is olight, how and why is this derived, and why is it required to draw these caps at infinity?

The second question I have is strongly related, the way I understand the vertex4f(x,y,z,w) calls, it works out as x/w y/w z/w. How is division by zero allowed? I am not familiar with this at all, my only intuition says that opengl somehow works this out as a limit; but that leads me to believe that these verticies would be interpreted as +/- INF, which does not make sense with how these caps are drawn.

I appreciate in advance any time somebody could spend explaining this, and I apologize for posting this in the advanced forum; but I had serious doubts that I would receive much help with this topic in the newbie one.

.oliver.