Jump to content
  • Advertisement
Sign in to follow this  
bencelot

Why does translating the modelview matrix affect texture generation?

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

Why hello there. I've successfully generated some nice shadows on my map, using multitexturing and texture generation to project a shadow onto it. This works fine on my map because I'm not translating it. I just found out though, that if I DO translate it.. then the texture coordinates are translated with it. Despite me setting them up as this: //Positioning Shadows in 3D GLfloat xPlane[] = {1,0,0, xEdge}; GLfloat yPlane[] = {0,1,0, yEdge}; glTexGenfv(GL_S, GL_OBJECT_PLANE, xPlane); glTexGenfv(GL_T, GL_OBJECT_PLANE, yPlane); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glScalef(1.0/float(mapWidth), 1.0/float(mapHeight), 1.0); glMatrixMode(GL_MODELVIEW); Which I would have thought (and liked) it to mean that the texture coordinates are going to be determined by their distance from xEdge and yEdge. But no. Infact, the textures are projected differently between this: glMatrixMode(GL_MODELVIEW); glPushMatrix(); glTranslatef(256,0,0); glBegin(GL_QUADS); glVertex2f(x,y+h); glVertex2f(x+w,y+h); glVertex2f(x+w,y); glVertex2f(x,y); glEnd(); glPopMatrix(); and this: glBegin(GL_QUADS); glVertex2f(256+x,y+h); glVertex2f(256+x+w,y+h); glVertex2f(256+x+w,y); glVertex2f(256+x,y); glEnd(); This wouldn't be a problem if I only wanted to project these shadows onto my map.. but I want to project it onto thousands of moving characters and particles.. all individually translated, scaled and rotated. Is there any way to make texture projection ignore what happens in the modelview matrix? Or am I going to have to updated the texture matrix with some long and costly equation everytime I want to update the modelview matrix? Thanking you, Ben.

Share this post


Link to post
Share on other sites
Advertisement
Problem solved!

I tried changing GL_OBJECT_PLANE to GL_EYE_PLANE and GL_OBJECT_LINEAR to GL_EYE_LINEAR, and it worked perfectly! What a fluke... took me by complete suprise. It was like a ninja.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!