Original Post
I''m trying to implement projective shadows, And i''m running into a weird bug. I''ve purposely not enable stencil buffering or any of that sort of thing, so that I can see if the result looks relatively correct. Anyway, right now, I''ve got the light at 0,1,0 and the plane at 0,-0.5,0. the object is in between. In this case, the shadow looks OK, but if i move the light, the shadow doesn''t "stretch" to move or anything. Instead, it rotates in place to face the light. I''ve checked with the nVidia tutorial on doing reflections and shadows, and I''m almost positive my matrix is 100% correct.
This is my code for generating the projection matrix, i create a 1-D size-16 array instead of a 2-D to be able to input it into glMultMatrixf() easier.
float dot;
dot = float(lights[light][0] * planes[plane].normal[0]) +
float(lights[light][1] * planes[plane].normal[1]) +
float(lights[light][2] * planes[plane].normal[2]) +
float(lights[light][3] * planes[plane].normal[3]);
//create a new size 16 array
float* projectMatrix = new float[16];
projectMatrix[0] = dot - lights[light][0] * planes[plane].normal[0];
projectMatrix[1] = 0.0f - lights[light][0] * planes[plane].normal[1];
projectMatrix[2] = 0.0f - lights[light][0] * planes[plane].normal[2];
projectMatrix[3] = 0.0f - lights[light][0] * planes[plane].normal[3];
// second column
projectMatrix[4] = 0.0f - lights[light][1] * planes[plane].normal[0];
projectMatrix[5] = dot - lights[light][1] * planes[plane].normal[1];
projectMatrix[6] = 0.0f - lights[light][1] * planes[plane].normal[2];
projectMatrix[7] = 0.0f - lights[light][1] * planes[plane].normal[3];
// third column
projectMatrix[8] = 0.0f - lights[light][2] * planes[plane].normal[0];
projectMatrix[9] = 0.0f - lights[light][2] * planes[plane].normal[1];
projectMatrix[10] = dot - lights[light][2] * planes[plane].normal[2];
projectMatrix[11] = 0.0f - lights[light][2] * planes[plane].normal[3];
// fourth column
projectMatrix[12] = 0.0f - lights[light][3] * planes[plane].normal[0];
projectMatrix[13] = 0.0f - lights[light][3] * planes[plane].normal[1];
projectMatrix[14] = 0.0f - lights[light][3] * planes[plane].normal[2];
projectMatrix[15] = dot - lights[light][3] * planes[plane].normal[3];
Any ideas? i can also post my drawing code, if that would help