Jump to content
  • Advertisement
Sign in to follow this  
supagu

OpenGL projective texture issues

This topic is 5134 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...

Share this post


Link to post
Share on other sites
Advertisement
Check my article "Projective Texture Mapping In OpenGL" that can be found on my home page. I hope that it will help you in solving the problem you are having.

Share this post


Link to post
Share on other sites
i seee you did something with the modelview matrix to generate the texture matrix? i thought the idea was to convert what the light sees to what the camera sees to generate to uv coords, how should the model view matrix be involved in this?

ps. couldnt find the article only code

Share this post


Link to post
Share on other sites
Quote:
Original post by supagu
i seee you did something with the modelview matrix to generate the texture matrix? i thought the idea was to convert what the light sees to what the camera sees to generate to uv coords, how should the model view matrix be involved in this?


If you are refering to the function "void SetupMatrix(float* Position, float* Rotation, float FOV)" then dont worry about the modelview matrix, I only use it to generate a matrix that I will then load in the texture matrix, this way I do not have to recalculate my matrix everytime but only the time when the projection needs to be changed.

Share this post


Link to post
Share on other sites
okay, other than that, my code pretty much follows your code as far as i could tell

are the vertex postions on light space converted to uv coords in camera space?

either way, should there be some involvement of camera position in determining the texture matrix?

another thing i noticed, i tried extracting the matrix after setting GL_TEXTURE was complete, and ocmpared it to
biasMatrix * projection * lightTransform and the matrices seem totaly different?! (both of which still dont work)

[Edited by - supagu on September 4, 2004 8:51:27 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!