Rendering Large Terrain
I am trying to render a large terrain in OpenGL. My terrain consists of multiple terrain blocks of size 1000x1000 meters (1001x1001 vertices).
Each block consist of multiple driangle strips drawn by means of the glMultiDrawElements(GL_TRIANGLE_STRIP, ...) function.
But when I for example create a terrain of size 6x6 kilometers (6x6 blocks) I get a poor performance (only about 2fps).
How could I improve It? Can I use triangle strips or should I use another primitive type if I want to use a LOD technique?
Is there a simple terrain LOD tutorial for beginers with a simple code samples which explains it step by step?
All tutorials I have found were too much theoretical or were very complex and complicated for learning.
Could you please help me?
Thanks so much
What OpenGL version and graphic card are you using?
Could you show us how are you drawing that meshes?
Edit: Triangle strips are (usually) one of the fastest modes so there's no problem with that.
I am using Nvidia GeForce gt555m (notebook) with OpenGL 4x, but I like to preserve compatibility with OpenGL 3x.
The terrain meshes are drawn by means of the glMultiDrawElements function, i. e. terrain of the size for example 1x1 km consists of 1000 triangle strips of width 1m and length of 1 km.
The vertices are stored in an float array of size 1000x1000x3. The first triangle strip has indices 0, 1000, 1, 1001... The second strip has indices 1000, 2000, 1001, 2001... etc...
I would like to use a LOD technique because I think that drawing a large terrain without LOD is too clumsy. But I don't know where to start...
- Save your height vertices in a height map
- Save a terrain block (chunk) as a VBO (preferrably much smaller than yours, 32x32 has proven to be good)
- Write a drawing function: Define what to draw and how detailed to draw it based on the distance to the camera
- Draw it instanced (all the necessary information for each chunk can be stored in 4 floats)
An old image of mine displaying the precision of the chunks can be found here.
Okay, so I should learn instanced rendering first. I have never did it...
Not necessarily. Most terrain rendering algorithms don't use instancing. I prefer clipmaps.
Take a look at vterrain.
If you're able to leverage tessellation, this approach is also noteworthy. Or this.
Tessellation shader approach is not superior to vertex shader approach because of at least two reasons: VS has wider support and there is no limitation on the size of the blocks.
Aleksandar: I didn't say it was superior or the only way - I just proposed it as another contemporary alternative. It's definitely better than ROAMing.
Sorry, I didn't want to offend you.
Definitely better! ROAM is a prehistoric algorithm.