• Advertisement

Archived

This topic is now archived and is closed to further replies.

Landscape Texturing

This topic is 6377 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, I''m using Dx7 Immediate mode - I''ve pretty much written my landscape engine, at least the programming side of it; I now need to sort out the texturing - which isn''t good at the moment. Can anyone point out "Tricks of the trade" or any tutorials on texturing a landscape? I require (currently) 2048x2048 worth of textures to map the entire landscape - even then it dont look great... Any help is much appreciated... Jack,

Share this post


Link to post
Share on other sites
Advertisement
Hmmm... dunno if this'll meet your requirments but...

I'm assuming your terrain is built up from a mesh, right?
If its built from triangles, then two tri's will make one
"square" of your mesh, like so:

(There was supposed to be a diagram of a triangle strip
to show you how two triangles form a "sector" but after
the fourth attempt I gave up. ;-))

(8 triangles making 4 "sectors") Ignore the dots, there there
'cause my original one messed up (only allows one blank space?)

Now, you now have a giant grid, like a chessboard. Each sector
can have info put in an array, like this(or whatever):
Terrain[50][50]
were the terrain is 50x50 sectors in dimensions. Make, say, 10
different "clear land" textures (or more for variety), 5 "rubble"
textures, etc.

Now, you only now have about 15 64x64 textures, which the
sectores point to. they can point to un-uniform/custom land
textures, at little performance cost. The idea is that instead
of having one HUGE texture, you just "tile" one (or more) texture
creating a varied (and nice) terrain. The technique works on
any terrain size, so if your maps 1000x1000, it will still only
use up 10/20 64x64 (128x128,256x256...) textures. Nice!

Hope it helps.

P.S. I've just read through this and it makes little sense :-)
If it doesnt help, I'll clarify it with another post

Edited by - ferrit on September 3, 2000 8:51:54 AM

Edited by - Ferrit on September 3, 2000 8:55:51 AM

Edited by - Ferrit on September 3, 2000 8:57:52 AM

Edited by - Ferrit on September 3, 2000 9:00:06 AM

Share this post


Link to post
Share on other sites
If you want to texture you terrain with one texture read this article:
http://www.tashco.com/terraintexturing.html

Yoshi

Share this post


Link to post
Share on other sites
Thanks,

I''ll read that article...

I think I get the previous one from Ferrit - but I''ll email you (If I can find your address)...

Jack,

Share this post


Link to post
Share on other sites
Hmmm... I think I understand what you want to know... how
to get the texture coords and how to organize your vertices?

Well, lets start with the vertices. If you''ve written a
to generate these vertices, great. If not, try below:

int width = 256;
int height = 256;
int total=0;

float fVerts = (float*)malloc((sizeof(float))*width*height*3); /* Allocate space for (256*256) vertices with an x,y and z*/

for(int ctr=0;ctr {
for(int ctr2=0;ctr2 { // Vertex number is total
fVerts[total] = ctr2; // Vertex X component is ctr2
fVerts[total+1] = 0; // Vertex Y component is height field (0)
fVerts[total+2] = ctr; // Vertex Z component is ctr
total+=3; // Increase total to be next vertex number
}
}

What this does is create a large grid, 256x256 vertices.
the "height" set to 256 isnt the height, as in y-coord, but
the height, as in grid height (thi makes sense?). Now, we have
two advantages: Our vertices in a nice, long array, but more
importantly, it is tah dah... a list of our vertices, ideal
for use with indexed stuff (tri lists,strips,etc.) Now,
assuming you''re using your planet-dwarfing texture, we need
to generate our texture coords. As you know, tex coords go
form 0-1 in the U direction (or our "width"), and 0-1 in the
V direction (our "height"). So, vertice[0][0] will have tex
coords U=0,V=0, and vertice[255][255] will have coords U=1,V=1
. With modification to the above code, be can generate
vertices AND texture coords for these vertices in one go. The
method for this is like so: let n be our vertice''s X coord.
U coord will be (n/256). Funkey monkeys! So, the code modified:

int width = 256;
int height = 256;
int total=0;
int TexTotal=0;

float fVerts = (float*)malloc((sizeof(float))*width*height*3); /* Allocate space for (256*256)

float fTexCoords = (float*)malloc((sizeof(float))*width*height*2); /* Allocate space for (256*256)

for(int ctr=0;ctr {
for(int ctr2=0;ctr2 { // Vertex number is total
fVerts[total] = ctr2; // Vertex X component is ctr2
fTexCoords[TexTotal] = (ctr2/width);
fVerts[total+1] = 0; // Vertex Y component is height field (0)
fVerts[total+2] = ctr; // Vertex Z component is ctr
fTexCoords[TexTotal+1] = (ctr/height);
total+=3; // Increase total to be next vertex number
TexTotal+=3; //Increase next TexCoord Number
}
}

if you need further explaining, dont hesitate to ask.

Share this post


Link to post
Share on other sites

  • Advertisement