   Simple shadow mapping problem - code and image inside [SOLVED]
  I'm having a weird problem with simple shadow mapping. Here's the codeglClearDepth(1.0f);float lightModelview[16] = {0};float lightProjection[16] = {0};   SCENE->Move();glDisable(GL_CULL_FACE);   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );    glLoadIdentity(); glPushMatrix();   gluLookAt(8.0f, 8.0f, 0.0f,  0.0f, 0.0f, 0.0f,    0.0f, 1.0f, 0.0f);  glMatrixMode(GL_PROJECTION);  glPushMatrix();  glLoadIdentity();  gluPerspective(45.0f, 1.0f, 4.0, 100);  glGetFloatv(GL_PROJECTION_MATRIX,lightProjection);    glPopMatrix();  glMatrixMode(GL_MODELVIEW);  glGetFloatv(GL_MODELVIEW_MATRIX, lightModelview);   glDisable(GL_LIGHTING); glShadeModel(GL_FLAT); glColorMask(0,0,0,0); SCENE->Render(); glBindTexture(GL_TEXTURE_2D, depthMap); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 512, 512); glShadeModel(GL_SMOOTH); glColorMask(1, 1, 1, 1);   glPopMatrix();   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );   glLoadIdentity();glViewport(0, 0, 800, 600);   glTranslatef(WORLD_TRANSLATION.x,WORLD_TRANSLATION.y,    WORLD_TRANSLATION.z-50);   glPolygonMode(GL_FRONT_AND_BACK, (doDrawWireframe) ? GL_LINE : GL_FILL);   glRotatef(angleY, 0.0f, 1.0f, 0.0f);   glRotatef(angleX, 1.0f, 0.0f, 0.0f);float s_plane[4] = {1.0f, 0.0f, 0.0f, 0.0f};float t_plane[4] = {0.0f, 1.0f, 0.0f, 0.0f};float r_plane[4] = {0.0f, 0.0f, 1.0f, 0.0f};float q_plane[4] = {0.0f, 0.0f, 0.0f, 1.0f};glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);glTexGeni( GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);glEnable(GL_TEXTURE_GEN_S);glEnable(GL_TEXTURE_GEN_T);glEnable(GL_TEXTURE_GEN_R);glEnable(GL_TEXTURE_GEN_Q); glMatrixMode(GL_TEXTURE);glLoadIdentity();float biasMatrix[] = {0.5f, 0.0f, 0.0f, 0.0f,  0.0f, 0.5f, 0.0f, 0.0f,  0.0f, 0.0f, 0.5f, 0.0f,  0.5f, 0.5f, 0.5f, 1.0f};glLoadMatrixf(biasMatrix);glMultMatrixf(lightProjection);glMultMatrixf(lightModelview);   glMatrixMode(GL_MODELVIEW);   glEnable(GL_TEXTURE_2D);   glBindTexture(GL_TEXTURE_2D,depthMap);   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE);   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);   glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE); SCENE->Render();glDisable(GL_ALPHA_TEST);glDisable(GL_TEXTURE_2D);glDisable(GL_TEXTURE_GEN_S);glDisable(GL_TEXTURE_GEN_T);glDisable(GL_TEXTURE_GEN_R);glDisable(GL_TEXTURE_GEN_Q);glDisable(GL_POLYGON_OFFSET_FILL);   glMatrixMode(GL_TEXTURE);glLoadIdentity();   glMatrixMode(GL_MODELVIEW);   glutSwapBuffers();And the image: It seems like the projection is wrong, and the sphere is capped by the frustum. What is it that i'm missing?EDIT:I solved it by increasing the frustum size :D[Edited by - Deliverance on May 5, 2009 11:58:48 AM]
  Try rendering the floor with the color of the depth map.  That will show you what the bounds of your frustum are to ensure you have the sphere inside the light frustum.   