View Full Version : 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?
02-02-2001, 02:18 AM
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.
XSize = 100;
YSize = 100;
v.x = 25;
v.z = 32;
float U = v.x / XSize; // = 0.25
float V = v.z / YSize; // = 0.32
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.