Getting a little closer. I've eschewed the technique used in the tutorial I linked to; As it doesn't run the same when I compile it vs. the provided binary I figure it's time to move on. My texture matrix appears to have decent values, and my depth map makes sense and is readable from what I understand. After adding a modelview matrix inverse, this is what I get now:
[attachment=13106:progress.png]
Though this result is similar to when my texture matrix had bogus data before. Here is my revised texture matrix setup:
static double modelView[16];
static double invmodelView[16];
static double projection[16];
// This is matrix transform every coordinate x,y,z
// x = x* 0.5 + 0.5
// y = y* 0.5 + 0.5
// z = z* 0.5 + 0.5
// Moving from unit cube [-1,1] to [0,1]
const GLdouble bias[16] = {
0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 0.5, 0.0,
0.5, 0.5, 0.5, 1.0};
// Grab modelview and transformation matrices
glGetDoublev(GL_MODELVIEW_MATRIX, modelView);
glGetDoublev(GL_PROJECTION_MATRIX, projection);
gluInvertMatrix(modelView,invmodelView);
glActiveTexture(GL_TEXTURE7);
glMatrixMode(GL_TEXTURE);
glLoadMatrixd(bias);
// concatating all matrice into one.
glMultMatrixd (projection);
glMultMatrixd (modelView);
glMultMatrixd (invmodelView);
// Go back to normal matrix mode
glMatrixMode(GL_MODELVIEW);
glActiveTexture(GL_TEXTURE0);
And I modified the vertex shader:
// Used for shadow lookup
varying vec4 ShadowCoord;
void main()
{
ShadowCoord= gl_TextureMatrix[7] *(gl_ModelViewMatrix*gl_Vertex);
gl_Position = ftransform();
gl_FrontColor = gl_Color;
}
I haven't altered the fragment shader from the original.