[C++, DX9] Heightmap/Terrain rendering, organising etc. Help needed

Started by
4 comments, last by mrr 14 years ago
I have came up with design problem with terrains. Basically if I make one big terrain for whole map, it will take a lot of memory, as well as time to render, and textures loaded would be devastating to RAMs. Splitting it into many small pieces, would cause a lot of CPU usage to loop, do all calls and calculate distance to determine if it's not too far away to decide render it or not. I've been told there's a way to draw Heightmap using Shaders, by heightmap (grayscale image) to the shader, and it'll draw automatically, however I failed to find any tutorial. My question is, could anyone tell me how to handle terrains/heightmap and how to do it with shader? Or there is any better way? Before I was using .x mesh for terrain, split into 100x100 sectors, but performance doesn't seem to be good. Also I noticed a lot of games render terrain depending on distance from player (in a circle shape, calculate distance to each vertex?), making smallest movement in any way was rendering more terrain in the way I moved, but my method makes it bumpy as my sectors are squarish not round, and they appear out of nowhere, instead of partly like that circle shaped one, or it doesn't matter? P.S. I need to be able to display a lot of terrain, without high CPU/performance or RAM usage.
Advertisement
there are alot of informations about how to render terrain from a heightmap.
google it with this search terms: directx terrain rendering
and you get some links how to render a terrain based on a heightmap.
when you want to speed up thinks you should look how to split you terrain
into smaller parts often called chunks.

there are alot of ways you can render a terrain from a heightmap.
but to get into it i would start simply and step by step look into more
complex solutions.

only with vertex shader version 3.0 you can look up texture informations inside a vertex shader. often called VTF vertex texture fetch.
You might want to google and research the following methods of efficiently rendering terrains (probably in order of simplicity):

Chunked LOD
Geomipmapping
Geoclipmapping

I believe you can achieve all of these using any 3d library (DX, OpenGl, etc), using shaders, although I haven't tried them in OpenGL or anything other than DX9.
Try Quadtree. Its easy to use and can also perform fast culling.
myWebSite : https://sites.google.com/site/vehement04/
Quote:I've been told there's a way to draw Heightmap using Shaders, by heightmap (grayscale image) to the shader, and it'll draw automatically, however I failed to find any tutorial.

I guess "Geometry clipmaps" are what you are looking for.

Additionally, have a look at vterrain.org. Here you can find plenty of information on terrain rendering.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
You could do like this.

* VBO With predefined block grid

* Load blocks (with texture heightmaps) into the GPU and have a shader do vertex displacement.

* A quadtree of block references to determine if blocks should be loaded into PC memory, GPU memory and if any should be discarded etc..at the bottom of the quad tree use a mesh of pointers linking all neighbours together to shift blocks during movement.

* Use same quadtree combined with frustum culling to determine what blocks should be rendered.

Now LOD can be added by having textures at different MIP levels and VBOs with matching grid density or just load different indices. T junctions can be fixed by changing the geometry of a the VBOs (load new indices) or by scaling vertex heights to match at LOD boundaries. But have never done this part.


This topic is closed to new replies.

Advertisement