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 4 of 4

Thread: Texture correction :O

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

    Texture correction :O

    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 .
    Here is a link to my last post about this topic. Btw,thanks everybody who read this!

    http://www.opengl.org/discussion_boa...535#Post312535
    Umer.

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

    Re: Texture correction :O

    I've answered your question already in your earlier post.
    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.

    Please don't open a new thread for the same question, especially if your question was already answered.

    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
    Junior Member Newbie
    Join Date
    Mar 2012
    Location
    Honduras
    Posts
    15
    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?

    Ive seen this article: http://www.xyzw.us/~cass/qcoord/
    I kinda understand how it works but not totally sure. Another thing is the example provided works only if the top has the same values, you can see that when running the sample.

    Again thanks so much for your help and I will aprreciate any advice you can give me
    Umer.

  4. #4
    Intern Contributor
    Join Date
    May 2008
    Location
    USA
    Posts
    96
    Umer, you're mishearing. You do not want to use glTexCoord. You have drawn a flat quad, on one plane, and you want it to act like it's in a 3D space. Adjust the vertices - not the texture coordinates - to take a square and tilt it in the 3D space until it looks like a trapezoid from your camera position. Now the trivial texture coordinates will just work.

    Bruce

Posting Permissions

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