Texture Perspective Correction!

Hi everybody, Im having trouble with my texture coordinates for a trapezoid quad :blush: I get a distorted image when trying to move each of my quad corners in different direction. I already posted this in here but could figure out how does it actually work. It would be very helpful if someone could help me understand this or how does glTexCoord4f(s,r,t,q) worksā€¦

In advance,thanks everybody who is viewing this.

Ps: A link to my last post related with this topic:

http://www.opengl.org/discussion_boards/ā€¦2426#Post312426

How do you transform your vertices? Perspective projection works properly only if the Z and W components of the clip space vertex positions are correctly set.

If you manually calculate only the X and Y coordinates of your vertices and the Z and W components are all the same for the vertices, these kind of issues can happen. But thatā€™s the correct result for those values.

Be sure to perform the perspective transformation properly and have the post-perspective transform Z and W coordinates in place. That is needed in order for the GPU to perform the perspective texture coordinate interpolation you need.

I assume you mean with ā€œsmoothā€ (perspectively correct) as opposed to ā€œnoperspectiveā€ interpolation.

Had the same question a while back and took a stab. See if this helps:

Hi!
Thanks for your helpā€¦ unfortunately this will show my ignoranceā€¦ I dont know how to calculate those values, Could you please tell me how to do that? I mean i.e.:
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 think this is wrong from my part cause doing it this way I get to see where the triangles join and cause a undesired texture. So how should I apply glTexCoord4f(s,t,r,q) with those vertex coordinates?

Again thanks all for your help!!

Hi!
Thanks for your helpā€¦ unfortunately this will show my ignoranceā€¦ I dont know how to calculate those values, Could you please tell me how to do that? I mean i.e.:
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 think this is wrong from my part cause doing it this way I get to see where the triangles join and cause a undesired texture. So how should I apply glTexCoord4f(s,t,r,q) with those vertex coordinates?

Again thanks all for your help!!