View Full Version : Shadows

11-29-2000, 09:54 AM
I am trying to learn how to do shadows in opengl and having been looking at scube.c found at http://www.sgi/com/software/opengl/glut/examples. In the code to produce the shadow are the lines...

myShadowMatrix(groundPlane, lightPos);
glTranslatef(0.0, 0.0, 2.0);
glMultMatrixf((const GLfloat *) cubeXform);

My question is "Why is
glTranslatef(0.0, 0.0, 2.0);
I know that it isn't called then the shadow does not appear in the correct place. But it seems like to magic to me. I understand what myShadowmatrix does and what the glMultMatrix call does but the translation escapes me entirely. Please help!

12-02-2000, 07:38 AM
the link didn't work for me (and i'm new to opengl) but the logical reason i see for the translate along the z axis is:
you're probably facing the face you're drawing the shadow plane to. the translation would move the shadow face above the object 2 units above the geometry plane.
(i really don't know though, and i'm sure there are many others on this forum that could reply more intellegently than i)


Michael Steinberg
12-02-2000, 11:25 AM
That would be correct, if a face offset would have the same result. Or, try to set depth test mode to GL_EQUAL and comment that line out. If it's just so simple, both ways will produce the same as the translate does.