# Thread: Texture Perspective Correction!

1. ## Texture Perspective Correction!

Hi everybody, Im having trouble with my texture coordinates for a trapezoid quad :\$ 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

2. ## Re: Texture Perspective Correction!

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.

3. ## Re: Texture Perspective Correction!

Originally Posted by UmerLaton
HIt would be very helpful if someone could help me understand this or how does glTexCoord4f(s,,r,t,q) works....
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:

* http://www.opengl.org/discussion_boa...;Number=273380

4. ## Re: Texture Perspective Correction!

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!!

5. ## Re: Texture Perspective Correction!

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!!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•