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

Thread: terrian + texture mapping

  1. #1
    Intern Contributor
    Join Date
    Jan 2001
    Posts
    58

    terrian + texture mapping

    i have a small terrain (non planar; more of a fractal pattern) and i want to put a 64 x 64 map on it. but i don't want the map to repeat, i want the whole thing stretched over the surface and ridges of the terrain. i don't really know how to generate automatic texture coordinates, so is there another simple way to accomplish this? so far i'm just using glTexCoord3d to apply the map. is there a better way?

  2. #2
    Intern Newbie
    Join Date
    Oct 2000
    Location
    Cov
    Posts
    36

    Re: terrian + texture mapping

    To stretch the texture over the entire surface you need to specify texture coordinate between 0-1 for each vertext in the grid.

    For the simple case of a grid you use the x and z elements of each vertex in the grid to generate the texture coordinate. To scale the vertex coordinate to lyn in 0-1 you divide it by the maximum extent of the grid on the axis you are using.

    e.g
    XSize = 100;
    YSize = 100;
    v.x = 25;
    v.z = 32;
    float U = v.x / XSize; // = 0.25
    float V = v.z / YSize; // = 0.32

    glTexCoord2f(U,V);

Posting Permissions

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