I've created a terrain in OpenGL using a heightmap image. The result is an dynamically allocated array that includes all the vertices of the terrain (x,y,z) with a stride of 3 like this:(firstvertexX,firstvertexY,firstvertexZ,secondvertexX,secondvertexY,thirdvertexZ...).
I also calculated the normals (in a similar array) and an extremely bad approximation of the supposed UVs of the terrain (using the ...normals) in order to render it.The rendering has no problem at all,except that as i said the UV approximation is really bad and the texture that is rendered has a "polygon" feel in it (using GL_TRIANGLE_STRIPS).
I want to clarify that i want the terrain to be created in OpenGl and not in any other programm like Blender. So i have to somehow specify a UV coordinate for each vertex in the array mentioned above that containes the vertices. I would also like to say that im not looking for a perfect UV solution(even if somehow there is one), but a way that does a rough approximation in order for the result to be decent.
So my questions are:
- Do the UV coordinates need to range from 0 to 1, with no consideration of the terrain's width and length or not?
- Does the UV coordinate array need to be the same length as the vertices array?
- Is there any simple algorithm or way that i could specify the UVs of the terrain?
The texture that is rendered:

The actual image from the web:

The code that specifies the creation of the arrays :
for (i = 0; i < terrainGridLength - 1 ; i++) { //z
for (j = 0; j < terrainGridWidth; j++) { //x
TerrainVertices[k] = startW + j + xOffset;
TerrainVertices[k + 1] = 20 * terrainHeights[(i + 1)*terrainGridWidth + (j)] + yOffset;
TerrainVertices[k + 2] = startL - (i + 1) + zOffset;
k = k + 3;
TerrainVertices[k] = startW + j +xOffset;
TerrainVertices[k + 1] = 20 * terrainHeights[(i)*terrainGridWidth + j] +yOffset;
TerrainVertices[k + 2] = startL - i + zOffset;
k = k + 3;
float x = RandomFloat(0.16, 0.96);
TerrainUVs[d] = x* (terrainNormals[ 3*((i+1 )*terrainGridWidth + j)]);
TerrainUVs[d + 1] = terrainNormals[3* ((i+1 )*terrainGridWidth + j) + 2 ];
x = RandomFloat(0.21, 0.46);
TerrainUVs[d+2] = x*(terrainNormals[ 3*((i+1 )*terrainGridWidth + j) +1]);
d = d + 3;
x = RandomFloat(0.3, 0.49);
TerrainUVs[d] = x*(terrainNormals[3* ((i )*terrainGridWidth + j) ]);
TerrainUVs[d + 1] = terrainNormals[ 3*((i )*terrainGridWidth + j)+2 ];
x = RandomFloat(0.4, 0.85);
TerrainUVs[d + 2] = x*(terrainNormals[3* ((i )*terrainGridWidth + j) +1]);
d = d + 3;
}
}

i+1may be out of array size. 3)GL_TRIANGLE_STRIPSdefines triangles by 0,1,2 - 1,2,3 - 2,3,4... not your way 4) How is related the texture to the normals? There are some different usages... - Ripi2