Dynamic Terrains and Vertex Buffers

Started by
0 comments, last by Roquqkie 18 years, 10 months ago
I have a terrain which is comprised of tiles. When the tile gets built it is tessellated based on the distance from the camera using a binary triangle tree, which means when I come to making the vertex buffer I never really know how many vertices there will be. Sure I could traverse it once to get the vertex count and another time to fill the buffer, but then I am doing twice the work (that's the way it works now). There could potentially be a large number of vertices, but then there could also be a very small number, so I don't want to allocate a large buffer and waste memory. What is the best way to handle this situation? Should I use a vector array and then copy it in a loop into the vertex buffer? Is there a more efficient way? Thank you! I am using Direct3D BTW.
Advertisement
Hmmm... I would probably advice you to go for a much more GPU-friendly algorithm.

I use Geomipmapping and what I do, is to:

Split my terrain into patches (e.g. 16x16 patches).
For each patch create a VBO with the patch vertices AND vertices for skirts.
Create one Index-buffer for each LOD.

Then when I update my terrain, I create a list for each LOD with the patches that belongs to that given LOD.

When I render my terrain, I traverse the list, set the LOD-Indexbuffer and render the VBO from the patch.

By including skirts for each patch with no subject to it's neighbours LOD, I get a VERY efficient terrain-renderer, which almost dosen't use the CPU at all!

To further optimize it, you could store only the heights for each patch and then move them using a vertex-shader... This way your memory-use is 1/3 of the usual!

Best regards,
Roquqkie

[Edited by - Roquqkie on June 17, 2005 6:01:03 AM]

This topic is closed to new replies.

Advertisement