Bump, with new info:
Here's a
screenshot showing:
Upper left: final render
Lower left: the shadow map
Lower right: The distance from each point to the light
Upper right: The corresponding point on the shadow map (i.e., the depth of the nearest occluder)
Look at the lower right - the ball is farther away from the light than the box, but it's darker (i.e., it's computed as closer). This seems to the main problem (but I'm not sure). Is there any reason it would do this? Is there an orientation bit that I may be flipping, or something?
Although I'm not sure it's relevant, here's the entire scene drawing code:
// draw floorfloat size = 10;glColor3f(0, 0, 1);glBegin(GL_QUADS); glNormal3f(0, 0, 1); glVertex3f(-size, -size, 0); glVertex3f(-size, size, 0); glVertex3f(size, size, 0); glVertex3f(size, -size, 0);glEnd();// draw ballGLUquadric *pQuad = gluNewQuadric();gluQuadricNormals(pQuad, GLU_SMOOTH);glColor3f(1, 1, 1);float bpos[3] = { bdist * cos(bangle), bdist * sin(bangle), bheight };glTranslatef(bpos[0], bpos[1], bpos[2]);gluSphere(pQuad, .5, 20, 20);glTranslatef(-bpos[0], -bpos[1], -bpos[2]);gluDeleteQuadric(pQuad);// draw air boxfloat box = 2;glColor3f(0, 1, 0);glTranslatef(-bpos[0], -bpos[1], bpos[2]);glBegin(GL_QUADS); glNormal3f(0, 0, 1); glVertex3f(-box / 2, -box / 2, box); glVertex3f(box / 2, -box / 2, box); glVertex3f(box / 2, box / 2, box); glVertex3f(-box / 2, box / 2, box); glNormal3f(1, 0, 0); glVertex3f(box / 2, -box / 2, 0); glVertex3f(box / 2, box / 2, 0); glVertex3f(box / 2, box / 2, box); glVertex3f(box / 2, -box / 2, box); glNormal3f(0, 1, 0); glVertex3f(box / 2, box / 2, 0); glVertex3f(-box / 2, box / 2, 0); glVertex3f(-box / 2, box / 2, box); glVertex3f(box / 2, box / 2, box); glNormal3f(-1, 0, 0); glVertex3f(-box / 2, box / 2, 0); glVertex3f(-box / 2, -box / 2, 0); glVertex3f(-box / 2, -box / 2, box); glVertex3f(-box / 2, box / 2, box); glNormal3f(0, -1, 0); glVertex3f(-box / 2, -box / 2, 0); glVertex3f(box / 2, -box / 2, 0); glVertex3f(box / 2, -box / 2, box); glVertex3f(-box / 2, -box / 2, box);glEnd();glTranslatef(bpos[0], bpos[1], -bpos[2]);// draw boxglColor3f(1, 0, 0);glBegin(GL_QUADS); glNormal3f(0, 0, 1); glVertex3f(-box / 2, -box / 2, box); glVertex3f(box / 2, -box / 2, box); glVertex3f(box / 2, box / 2, box); glVertex3f(-box / 2, box / 2, box); glNormal3f(1, 0, 0); glVertex3f(box / 2, -box / 2, 0); glVertex3f(box / 2, box / 2, 0); glVertex3f(box / 2, box / 2, box); glVertex3f(box / 2, -box / 2, box); glNormal3f(0, 1, 0); glVertex3f(box / 2, box / 2, 0); glVertex3f(-box / 2, box / 2, 0); glVertex3f(-box / 2, box / 2, box); glVertex3f(box / 2, box / 2, box); glNormal3f(-1, 0, 0); glVertex3f(-box / 2, box / 2, 0); glVertex3f(-box / 2, -box / 2, 0); glVertex3f(-box / 2, -box / 2, box); glVertex3f(-box / 2, box / 2, box); glNormal3f(0, -1, 0); glVertex3f(-box / 2, -box / 2, 0); glVertex3f(box / 2, -box / 2, 0); glVertex3f(box / 2, -box / 2, box); glVertex3f(-box / 2, -box / 2, box);glEnd();