okay trying to get projective textures working, from this link:
http://www.opengl.org/resources/tutorials/sig99/advanced99/notes/node80.html
so, this is how i set up the texture matrix:
[cpp]
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
// Offset
glTranslatef(.5f, .5f, .0f);
// Bias
glScalef(.5f, .5f, 1.0f);
// light frustum
projection.SetM();
// light view
light.LookAtM();
GLfloat Splane[] = {1.f, 0.f, 0.f, 0.f};
GLfloat Tplane[] = {0.f, 1.f, 0.f, 0.f};
GLfloat Rplane[] = {0.f, 0.f, 1.f, 0.f};
GLfloat Qplane[] = {0.f, 0.f, 0.f, 1.f};
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, Splane);
glEnable(GL_TEXTURE_GEN_S);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_T, GL_EYE_PLANE, Tplane);
glEnable(GL_TEXTURE_GEN_T);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_R, GL_EYE_PLANE, Rplane);
glEnable(GL_TEXTURE_GEN_R);
glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_Q, GL_EYE_PLANE, Qplane);
glEnable(GL_TEXTURE_GEN_Q);
[/cpp]
hrmm the inverse of the light transform seems to work better, but still not properly.
projection is the same projection i use on my camera and light
light.LookAtM multiplys the lights view matrix with the existing ogl matrix
what im doing is rendering the scene from the light after that like so:
[cpp]
glMatrixMode(GL_MODELVIEW);
light.LookAt();
transform2.SetM(); // a matrix that spins my quad
//draw a quad
[/cpp]
what i would want to see if the texture being projected strait on my screen, top left of the screen being 1 corner of the texture, while the bottom right would be the opposite corner… and would be projected strait on to the scene right, or would it only be like this in ortho mode?
what i get is just weird… will post a demo if people need to see whats going on…