# Directx9 terrain vertex counts

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

## Recommended Posts

Hi I'm using a height-map to generate a terrain mesh, but there are way too many vertices. Lets say the height-map is 512x512 pixels then the total number of vertex is = 512*512*2 = 524288 assuming each pixel counts for 1 square and 1 square is made out of 2 triangles. This many triangles really slows things down!!!! Is there any way to reduce the number of triangles without loosing too much detail, or even better is there a way to dynamically reduce the amount of triangles for terrain that is far way. Thus keeping a high triangle count for near terrain and a lower count for far terrain. Sorta like making the terrain's triangle count or detail a function of the distance away from the viewer's point of view / camera??? Any help will be greatly appreciated. Thanks

##### Share on other sites
I never used it but you can create a lower quality versions of the terrain. Split the terrain into 16x16 parts, depending on the distance between camera and the terrain part, use the lower res models for the farther parts of the terrain.

http://en.wikipedia.org/wiki/Level_of_detail

##### Share on other sites
Thx this is what i was looking for. I'll read more about this. If i don't get it working, I'll be back then to post more MUhahahaha. lol anyway thx for the advice

##### Share on other sites
also google CLOD, ROAM, geomipmapping. there are many level of detail methods.

EDIT: Also, each pixel in a heightmap should be a vertex, not a quad. otherwise your terrain would end up being a bunch of quads of different heights, all parallel with the ZX plane. for a 512x 512 grid sized terrain you would need 513x513 sized heightmap.

##### Share on other sites
Adding to what the others said :

...and if you use Triangle strips would be a better idea as you would need N+2 vertices aka (512*512*1)+2 that is quite better.

##### Share on other sites
Quote:
 Original post by feal87Adding to what the others said :...and if you use Triangle strips would be a better idea as you would need N+2 vertices aka (512*512*1)+2 that is quite better.
If you render the whole terrain in one go, yes. However, GPUs these days are best optimised for rendering indexed triangle lists, so you'd probably be better overall to use an indexed triangle list for rendering - and making LOD'd data into triangle strips can be a pain in the ass.

##### Share on other sites
Quote:
 Lets say the height-map is 512x512 pixels then the total number of
height values is 262144
Quote:
 assuming each pixel counts for
1 height value.

To create a terrain mesh with 1:1 mapping of the height map, it results in 511*511*2 = 522242 triangles. If correctly implemented it shouldn't be any problem for any modern graphics processor.

You should use indexed triangles lists (or strips) for drawing. This way, you'll need only 262144 vertices for drawing the 511x511 squares mesh.

You may also want to check 'Geometry clipmaps' for efficient terrain rendering.

Cheers!

[Edited by - kauna on May 9, 2010 12:58:18 PM]

##### Share on other sites
Thanks to all of you who replied =)

The reason why i'm saying 522242 is a lot, is because my frame rate has dropped 4 times. I used to get 400~500 FPS but with the terrain in i get +- 100 FPS. I am using a triangle list as well as an vertexIndexBuffer/verticeIndexBuffer.

The idea is I want a large map where the user can roam/explore/walk (or whatever) without having to render each and very detail in the map. I realized that if the map is flat and infinity large then at a certain distance the vertexes will be smaller than the size of one pixel thus these do not have to be rendered. And then on top of that the further the vertexes are the less will be needed to render a relatively good looking terrain.

The type of answer i was looking for is the LoD techniques that shultays pointed out for me. And what Burnt_Fyr pointed out (CLOD, ROAM, geomipmapping). I would like to ask one last thing here: Is there any hardware implementations for the above mentioned techniques?

Thanks again good people

##### Share on other sites
Quote:
 Original post by KapoefThe reason why i'm saying 522242 is a lot, is because my frame rate has dropped 4 times. I used to get 400~500 FPS but with the terrain in i get +- 100 FPS. I am using a triangle list as well as an vertexIndexBuffer/verticeIndexBuffer.
400 FPS is 2.5ms per frame, 300 FPS is 3.3ms per frame - you're talking about a 0.8ms difference, which isn't really relevant. If you dropped from 110 FPS to 10 FPS, it'd be a bigger deal.

How are you rendering your terrain? For best performance for a terrain that size, you'd probably be best using a static vertex and index buffer and drawing the entire terrain in a single DrawIndexedPrimitive() call.

For larger terrains, you'll get better performance from using a LOD system, as others have said.

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 12
• 15
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633354
• Total Posts
3011494
• ### Who's Online (See full list)

There are no registered users currently online

×