Page 1 of 4 1234 LastLast
Results 1 to 10 of 40

Thread: How to display the texture coordinate of an object?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296

    How to display the texture coordinate of an object?

    Say the object has n vertices and after a series of transf it has displayed on the screen.
    then how to display their texture coordinates of these n vertices? or print out their list value?

  2. #2
    Senior Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    281
    The simplest way to visualize the texture coordiantes is to write them out as color in the fragment shader.

    For 2D texture coordinates, the s component ends up in the red channel and the t component in the green
    channel. More redish color means big s and rather small t, more green means small s and large t. Yellowish
    colors means s and t are roughly equal with dark yellow being small values and bright yellow large values.

    You can see the smooth transitions of the texture coordinates as they are interpolated over the triangle areas.



    Of course, you could also use the texture coordinates to map a texture image onto the mesh. Something like a
    debug texture with a regular grid on it.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    Thanks, I wish to get their values coordiinates, not color. ntor take account of interpolate, either at present.
    could you show a couple of code examples? or where can download that?

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,109
    If you want to capture the output of the vertex shader, use transform feedback mode.

    If you want something else, you'll need to clarify your question.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    Quote Originally Posted by GClements View Post
    If you want to capture the output of the vertex shader, use transform feedback mode.

    If you want something else, you'll need to clarify your question.
    Nor vertex shader output, either. just want to get the vertices' texture coordinate values. This likes this,
    A group of vertices of an object, through project to display on scteen.
    glMatrixMode(GL_PROJECT); gkPerspective(...); glLoadIdentity();
    glMatrixMode(GL_MODELVIEW); glLoadIdentity();
    ....then input vertices coordinate data........
    ater cpu or gpu calculate, the object is projected on screen, Then how to get the its texture coordinate values?

  6. #6
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    If derive individually, I can use Mm*Mp*vec4f(...)^T; but how to get it from api command?

  7. #7
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,676
    Texture coordinates are not in any way affected by the projection or modelview matrices (the texture matrices can, but you didn't say if you're setting them). So the texture coordinates will simply be whatever you passed.

    The vertex positions are affected by the matrices. And yes, you can transform the positions in the way you describe.

    Also:

    Code :
    glMatrixMode(GL_PROJECT); gkPerspective(...); glLoadIdentity();

    The glLoadIdentity() here undoes the perspective projection matrix setup.

  8. #8
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    Quote Originally Posted by Alfonse Reinheart View Post
    Texture coordinates are not in any way affected by the projection or modelview matrices (the texture matrices can, but you didn't say if you're setting them). So the texture coordinates will simply be whatever you passed.

    The vertex positions are affected by the matrices. And yes, you can transform the positions in the way you describe.
    .
    Im aftraid, I make no sense of it. would u please show a sample?

    lso:

    Code :
    glMatrixMode(GL_PROJECT); gkPerspective(...); glLoadIdentity();

    The glLoadIdentity() here undoes the perspective projection matrix setu
    Most of codes used to invoke it. it will calibrate center position.

  9. #9
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    btw, don't show us how a sphere, cycline or cube map to texture coordinate. I know this mapping.

  10. #10
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,676
    Quote Originally Posted by reader1 View Post
    Im aftraid, I make no sense of it. would u please show a sample?
    A sample of what? You asked how to get the texture coordinates you're using to render something. I just said that, unless you're using a texture matrix or texture coordinate generation, you already have those texture coordinates. You had to have them, because you were the one who passed them to OpenGL. And unless you're using a texture matrix or coordinate generation, those texture coordinates will be used as is.

    Now, if you're concerned that what you think you're passing isn't what OpenGL's actually getting, that's one thing. But Agent D's suggestion to simply render the texture coordinate values as colors would be sufficient to determine if the values are at least approximately what they ought to be.

    Now, if you are using a texture matrix or texture coordinate generation (which should have been mentioned, since these are fairly rarely used features), that's another matter entirely. Your only recourse is to read the OpenGL specification's sections on whatever generation method you're using, and mirror that mathematics in your code.

    Quote Originally Posted by reader1 View Post
    Most of codes used to invoke it. it will calibrate center position.
    No, it does not. Other code call glLoadIdentity before calling gluPerspective. That's the important point. It's like doing this:

    Code :
    a = 5;
    a = 0;

    `a` isn't 5 after this code is executed.

Page 1 of 4 1234 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 03-03-2014, 06:44 PM
  2. Get texture coordinate to framebuffer object
    By anuwat_boy in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-24-2013, 10:33 PM
  3. *world coordinate* vs *object coordinate*
    By ehsan2004 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-18-2005, 07:08 AM
  4. Converting window to display coordinate
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-15-2003, 11:20 PM
  5. mapping windows client coordinate to object coordinate
    By sohail in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 04-19-2003, 07:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean