I’ve written a basic Quadtree LOD engine which renders a 256x256 terrain mesh by dividing it into 16 (4x4) sections where a large texture tile is stretched across each (4x4) section.
Each texture tile is 256x256 pixels.
ignore the LOD part actually, it’s irrelevant to the problem
In order to get the texture coordinates for each triangle, I take the actual (x, z) position on the map and divide the x and z values by a stretching constant (64.0 in this instant, as 4 textures of 256 size fit across either length). This limits the first tile to the range 0.0 - 1.0.
This means I have texture coords across the length of the terrain for each axis like:
(tile 1: 0.0 - 0.999~) (tile 2: 1.0-1.999~) (tile 3: 2.0 - 2.999~) (tile 4: 3.0-3.999~)
With GL_REPEAT the landscape looks like: http://www.arkiruthis.f9.co.uk/lod_1.jpg
With GL_CLAMP the landscape looks like: http://www.arkiruthis.f9.co.uk/lod_2.jpg
(i.e., only the top right tile (1 out of 16) is rendered correctly)
With GL_CLAMP and a check on each set of vertices (e.g. (x%64)/64.0, (z%64)/64.0) I get the edges of the triangle mesh repeating whole sections of the texture itself.
http://www.arkiruthis.f9.co.uk/lod_3.jpg
Any ideas?
[This message has been edited by ceenda (edited 05-21-2002).]