PDA

View Full Version : Texture Perspective Correction!



UmerLaton
04-16-2012, 01:36 PM
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 (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Main=60176&Number=3124 26#Post312426)

aqnuep
04-16-2012, 03:15 PM
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.

Dark Photon
04-16-2012, 03:55 PM
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_boards/ubbthreads.php?ubb=showflat&Number=273380

UmerLaton
04-17-2012, 03:33 PM
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!!

UmerLaton
04-20-2012, 10:17 AM
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!!