PDA

View Full Version : Reflection always shifted to the right



soconne
10-30-2004, 05:56 AM
For some reason I just recently noticed that my reflections are shifted to the right, no matter what direction I am facing in the scene. Here's what I mean

http://cs.selu.edu/~soconnell/pic

I'm using the same exact code found here to perform the texture matrix manipulations
http://hem.bredband.net/grahei/articles/projtexture/projtexture.htm

I had actually fixed this problem before, but I can't remember how I did it. Basically, I've already tried setting the Window Width and Height to 512 512, with the reflection texture set to a size of 512, so that the aspect ratio is always 1.

Here's the basic layout of the code for setting up the texture matrix


static float planeS[4] = { 1.0f, 0.0f, 0.0f, 0.0f };
static float planeT[4] = { 0.0f, 1.0f, 0.0f, 0.0f };
static float planeR[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
static float planeQ[4] = { 0.0f, 0.0f, 0.0f, 1.0f };

static float matProj[16];
static float matModel[16];
static float biasMatrix[16] = { 0.5f, 0.0f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f,
0.0f, 0.0f, 0.5f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f };

glBindTexture(GL_TEXTURE_2D, m_TextureID);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

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);

glTexGenfv(GL_S,GL_EYE_PLANE,planeS);
glTexGenfv(GL_T,GL_EYE_PLANE,planeT);
glTexGenfv(GL_R,GL_EYE_PLANE,planeR);
glTexGenfv(GL_Q,GL_EYE_PLANE,planeQ);

glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_GEN_Q);

glGetFloatv(GL_PROJECTION_MATRIX,matProj);
glGetFloatv(GL_MODELVIEW_MATRIX,matModel);

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(0.5, 0.5, 0.5);
glScalef(0.5f, 0.5f, 1.0f);
glMultMatrixf(matProj);
glMultMatrixf(matModel);
glMatrixMode(GL_MODELVIEW);
and Here's what I do when updating the texture


glActiveTextureARB(GL_TEXTURE0);
glDisable(GL_CLIP_PLANE0);

// copy the screen into our texture
glBindTexture(GL_TEXTURE_2D,m_TextureID);
glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,m_Text ureSize,m_TextureSize);

// clear the depth and color buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// set the viewport back to the original size
glViewport(m_Viewport[0],m_Viewport[1],m_Viewport[2],m_Viewport[3]);

glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
Anybody remember how to fix this shift?