Why glVertex4f for infinite Shadow Volumes?

Hi,

I’m working on an infinite shadow volumes approach for my 3D engine, and I’ve been using the infiniteShadowVolumes.java as a guide. This is the shadow demo included with JOGL.

What I am confused about is how to use glVertex4f?

When the demo renders the edge silhouettes, and triangles for the caps the QUADS and TRIANGLES are defined using glVertex4f.

So for each point there is a XYZW, and I’m confused as to why W is sometimes 1 or 0

What effect does the W parameter have on glVertex4f in the context of triangles and quads, and why does the demo brake if I change it to glVertex3f?

I am guessing that this W can effect the normal of the triangle or quad? I think??

The OpenGL documentation explains Triangles and Vertex4, but not in the context of using them together.

A vertex with w == 0.0 will move to infinity (that’s how you get infinite shadow volumes). A vertex with w == 1.0 will stay in place (in x,y,z that is). With glVertex3f you’re always implicitly passing a 1.0 w, which breaks the shadow volume geometry.

(Edit)

This might be helpful (from nVidia’s SDK): External Triangles