okay, i’ve been working on projective texturing trying to get it working, and think i finally figured out whats going on:
instead of rotating around origin of the world as i want, it looks as if its rotating around my camera!
demo showing the funk:
http://mathewstwins.customer.netspace.net.au/temp/shadowmap.zip
uses first person controls to steer camera, as you can see, as the camera moves, so does the projective texture
the 3 coloured lines show where the depth map is being rendered from, and where it should be being projected from.
heres how i calculate the projection matrix:
static void loadTextureProjection()
{
Matrix4 mBias(0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.5, 0.5, 0.0, 1.0);
glMatrixMode(GL_TEXTURE);
mBias.Set(); // set this matrix
gluPerspective(45.0f, 1.0f, 1.0f, 4.0f);
Matrix4 trans = light.GetTransform();
trans.SetM(); // multiply with existing matrix (lights model view matrix)
glMatrixMode(GL_MODELVIEW);
}
then to render:
loadTextureProjection();
glEnable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_GEN_Q);
glMatrixMode(GL_MODELVIEW);
camera.LookAt(); // sets cameras model view matrix
//render my shapes here
im guessing i need some camera related matrix when producing the projective matrix? but what and in what order?
thanks in advance