Archived

This topic is now archived and is closed to further replies.

The infinite plane of a projective texture

This topic is 5174 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

Hey, When using projective textures I kinda noticed, that the texture I use is repeated on an infinite plane - so when I rotate the "projector" they will be visible and spoil the illusion of a projected texture :D Anyone who knows what''s wrong? Below I have posted my projection init code... I have tried both to use gluPerpective() and to create my own perpective matrix and then mult it... GLvoid ProjectTexture(GLfloat yaw, GLfloat pitch, GLfloat roll, CVector3 vPos){ CMatrix projMatrix, mMatrix; projMatrix.mMatrix[0] = cosf(90.0f / 2); projMatrix.mMatrix[5] = cosf(90.0f / 2); projMatrix.mMatrix[10] = sinf(90.0f / 2) / (1.0f - 0.1f / 1.0f); projMatrix.mMatrix[11] = sinf(90.0f / 2); projMatrix.mMatrix[14] = -projMatrix.mMatrix[10] * 0.1f; projMatrix.mMatrix[15] = 0.0f; glGetFloatv(GL_MODELVIEW_MATRIX, mMatrix.mMatrix); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glTranslatef(0.5f, 0.5f, 0.0f); glScalef(0.5f, 0.5f, 1.0f); //gluPerspective(90.0f, 1.0f, 0.1f, 0.0f); glMultMatrixf(projMatrix.mMatrix); glMultMatrixf(mMatrix.mMatrix); glTranslated(0, 0, 0); glRotatef(rotateY, 0, 1, 0); glRotatef(rotateX, 1, 0, 0); glMatrixMode(GL_MODELVIEW); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_GEN_R); 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_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); }

Share this post


Link to post
Share on other sites
You mean that the texture is projected on all primitives, not just the one you want it on? If this is the problem you''re having, you need to use the NVIDIA register combiners or Cg to do a simple test to determine if a fragment should have the projective texture applied or not. This tutorial demonstrates the equation you have to use...

[Insert witty signature here]

Share this post


Link to post
Share on other sites
That''s not the problem - but thanks anyway... :D

The problem is when I rotate inside the texture matrix - so I can focus my projected texture onto something - then I see some odd lines going from the texture to the end of the projective texture projection plane''s 4 sides... one to the top, one to the bottom, you get my point - what is more wierd is, that when I rotate enought (90) I see the ends of the two texture planes...

It''s very hard to explain... But try this...

I have two planes -> a forplane and a backplane -> I have projected a texture to the forplane (it also projects on the backplane) -> (the odd part) from the texture four lines are strechting to each end of the plane, on which the texture is

These planes ought not to be there, am I right?

Share this post


Link to post
Share on other sites