projective textures

Alright. I know to get the projection matrix from the point of view from the light source.

now what? I’ve seen tuts (very short ones) on this but they leave it at that and say use texture coord generation. i’ve done sphere mapping with TCG but how do you apply the projected texture?

Any help would be appreciated. Thanks

You must use eye linear texcoord generation for this.

You have to generate s, t and q coordinates. For their eye planes you load the corresponding rows from the light’s projection matrix. Here’s the code for it, it’s in Delphi but you should get the idea.

glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_Q);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, addr(lMatrix[0, 0]));
glTexGenfv(GL_T, GL_EYE_PLANE, addr(lMatrix[1, 0]));
glTexGenfv(GL_Q, GL_EYE_PLANE, addr(lMatrix[3, 0]));

Please note that opengl stores it’s matrice in column-major order, so if you get the matrix from opengl, you have to transpose it before you do this.

-Ilkka

like this?

So draw the object (wall,actor,floor,etc).
enable blend
Draw object again with linear TCG.
disable blend

Thanks. I’ll give it a try