Results 1 to 5 of 5

Thread: OpenGL - 2D - Skewing/distorting texture vertically along a line

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Quote Originally Posted by Ñuño Martínez View Post
    Actually I don't understand what's your problem. May be you can post an image showing what's not working.

    I think you can get it by using 2D, discarding the "Z" axis. Better if you use orthogonal to prevent transformations.
    Unfortunatly, I'm unsure what your saying XD
    I am already rending in 2D, that's what zenGL does, although I'm unsure if it's in orthogonal mode, how do you change projections with OpenGL?

    Quote Originally Posted by User137 View Post
    I recently discovered on some quads, that texture isn't going smoothly along the whole image. I am unsure how this would look, but i would try by adding 1 vertex in the average middle point of quad. That way you would render it as 5 point GL_TRIANGLE_FAN, where v0 is center of quad.
    It's not the texture not matching up or not being smooth that's the issue.

    I'll try and actually show the issue:


    If you look at the slope the texture doesn't run along the line (The horizontal lines on the brick wall are meant to become parallel to the slope of the wall).
    This is going across two, up two and as you can see from the images in the one above going one and and one across results in the correct distortion.
    Here's one with a triangle overlay:


    And here (in blue) is the path it follows, and (in yellow) the path it should follow:


    Basically when the y-differnce is greater than cGridsize the texture is incorrectly distorted, making the horizontal lines on the texture not parallel to the top/bottom of the wall.


    Edit: I just got it to work... and it was stupidly simple!

    TexCoord[0].x := Tri[0].x/cGridsize;
    TexCoord[0].y := Tri[0].y/cGridsize;

    TexCoord[1].x := Tri[1].x/cGridsize;
    TexCoord[1].y :=Tri[0].y/cGridsize+1;

    TexCoord[2].x := Tri[3].x/cGridsize;
    TexCoord[2].y := Tri[0].y/cGridsize+1;

    All I have to do is make it so that it doesn't repeat along the y axis because apparently the texture was repeating vertically, when it shouldn't >.>

    Sorry to have wasted your time, and thanks for trying to help me out! XD
    Last edited by Draghi; 31-12-2012 at 12:27 AM.

Tags for this Thread

Bookmarks

Posting Permissions

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