View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Terrain question

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1boldyman  Members

Posted 20 July 2001 - 04:11 AM

Hi, I am reading the book opengl game programming and i am playing with the code of chapter 8/10 (Textured heightfield terrain). I have a question about texturing the terrain. The code from the book uses one (grass) texture and put this texture on every quadrilateral. So in fact they use 1 texture and place let say 2000 times and the terrain is filled with green grass. I downloaded some other terrain demo''s and they all used ONE texture to cover ALL of the terrain, not putting the texture on ONE quadrilateral. They some howe broke up the texture in pieces that fit on one quadrilateral. I hope i make any sense Can some explain to me how they can use one texture to cover all of the terrain or even better some code. Thanks BoldyMan

### #2bobatefrei  Members

Posted 20 July 2001 - 05:01 AM

You should see the Demeter terrain engine at http://www.terrainengine.com/

Personnaly, I put only one texture on every quadrilateral but I use colors to change his aspect...

### #3boldyman  Members

Posted 20 July 2001 - 05:11 AM

How can you change the colors ? Do have some example code or
do you now a site ?

### #4Khawk  Senior Staff

Posted 20 July 2001 - 06:29 AM

The flag demo in the same chapter shows how to apply a single texture to a grid like you want to do for the terrain. Remember, the terrain is just a grid with varying y-values for the height.

To spread the texture over a bunch of poly's, you need to calculate the texture coordinates for each vertex that is being texture mapped. When applying 1 texture per quad, the values range from 0.0 to 1.0, right? Well, when applying 1 texture to 10 quads, the texture coordinates for each quad will range from n/10 to (n+1)/10, where n is the index value for the current grid vertex.

Just take a look at the flag demo. It explains things better than I can at the moment.

Kevin

### #5bobatefrei  Members

Posted 21 July 2001 - 05:06 AM

I change the color of each vertex with the glColor function (don''t forget to call glShadeModel(GL_SMOOTH) to have a nice interpolation).

Green vertexs looks like grass, white like snow...

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.