PDA

View Full Version : Texture correction :O

UmerLaton
04-24-2012, 10:34 AM
Please can someone help me understand glTexCoord4f(s,t,r,q)? Ive posted this before but couldnt find a answer for my problem. I want to know how to get the right values for s,t,r,q in texture coordinate. What I am trying to do is get a perspective correction for my texture when i map it into a trapezoid .

aqnuep
04-24-2012, 01:59 PM
The problem is that your Z and W coordinates for the vertices are 0.f and 1.f respectively thus the GPU thinks that the points rely in the same plane parallel to the near plane thus it thinks that it does not require any perspective correction.

You need to set your Z and W coordinates (together with your X and Y coordinates) using a proper projective transformation that transforms a square/rectangle into your trapezoid.

UmerLaton
04-26-2012, 07:04 PM
Hi aqnuep,
Thanks for your help in both post. Sorry you are right I shouldnt have post this again.!
Like I said before I dont know how to do that which you are specifying me to do. Any sample you can give me would be great... or i.e. how should i get the right values for this:

glTexCoord2f(0.0f,1.0f); glVertex3f(2.5f,1.0f, 0.0f); // Top Left Of The Texture and Quad
glTexCoord2f(1.0f,1.0f);glVertex3f(-1.0f,1.4f, 0.0f); // Top Right Of The Texture and Quad
glTexCoord2f(1.0f,0.0f);glVertex3f(1.2f,0.0f 0.0f); // Bottom Right Of The Texture and Quad
glTexCoord2f(0.0f,0.0f);glVertex3f(-0.4f,-0.5f 0.0f); // Bottom Left Of The Texture and Quad

I know I have to use glTexCoord4f to get the right perspective but i dont know how to set the q coordinate :\$.... Do you know how to do this?