Hi all,
I am farily new to OpenGL. I am trying to do a projective texture, but I need float precision in my texture. I am not quite sure how floats render, particularily small and negative numbers. Anyways, I first started playing around with projective textures using GL_TEXTURE_2D as the target and GL_LUMINANCE as the internal format. I got everything working beautifully.
I then tried to load my texture, which has float format, but found that GL_LUMINANCE doesn't have 32-bit precision. I cannot find a 32-bit precision internal format for GL_TEXTURE_2D, so I went to the GL_TEXTURE_RECTANGLE_ARB target with GL_FLOAT_R32_NV as the internal format. Everything loads and stores fine.
Here's the problem. The projective texture is completely screwed up now. I was starting with an identity matrix and then offsetting and scaling to convert the coordinates from [-1,1] to [0,1]. This used to put the projective texture shooting down the negative z axis, but now I have no idea what the orientation is.
This is what my code used to look like in order for doing this:
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(0.5, 0.5, 0.5);
glScalef(0.5, 0.5, 0.5);
I know that GL_TEXTURE_RECTANGLE_ARB uses non-normalized coordinates ([0,width] instead of [0,1]), but I am not sure how to change the glTranslatef statement. I am also not sure if I have to change the texture generation planes. Before I was just using the identity values as well:
// texture coord generation
GLfloat eyePlaneS[] = {1.0, 0.0, 0.0, 0.0};
GLfloat eyePlaneT[] = {0.0, 1.0, 0.0, 0.0};
GLfloat eyePlaneR[] = {0.0, 0.0, 1.0, 0.0};
GLfloat eyePlaneQ[] = {0.0, 0.0, 0.0, 1.0};
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, eyePlaneS);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_T, GL_EYE_PLANE, eyePlaneT);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_R, GL_EYE_PLANE, eyePlaneR);
glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_Q, GL_EYE_PLANE, eyePlaneQ);
Do I have to scale these by the width and height (or inverse of them)?
Lastly, do textures in GL_FLOAT_R32_NV actually show up correctly when rendered? Either I see nothing at all (which could be due to the orientation being completely off), or something completely wrong.
If anyone has ever tried this before or has some suggestions, I would love to hear from you.
Thanks.