Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Texture Perspective Correction!

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2012
    Location
    Honduras
    Posts
    15

    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
    Umer.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    941

    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.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  3. #3
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882

    Re: Texture Perspective Correction!

    Quote 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. #4
    Junior Member Newbie
    Join Date
    Mar 2012
    Location
    Honduras
    Posts
    15

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

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2012
    Location
    Honduras
    Posts
    15

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

Posting Permissions

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