What are the pros and cons of using a heightmap vs a model in 3D games

984 views Asked by At

I am learning how to program an OpenGL game engine in Java. I've done loading models from files already but next up is heightmaps and I'm wondering what are the benefits of using a heightmap to generate 3D terrain as opposed to a list of Z-axis values or a 3D model? Does it depend on the detail of the terrain or is it just more efficient to use a heightmap?

Some that I can think of:

Heightmap pros:

  • Smaller file, since the game will generate it into memory at runtime.
  • More optimized algorithms for manipulation of an n^2 image?
  • Easier procedural generation.

Heightmap cons:

  • Problem with steep angles and overhangs are impossible.
  • Don't seem to be as accurate as models.
  • Are they that helpful for making terrain if you aren't procedurally generating it?
1

There are 1 answers

0
Denis On

If you refer to a gray-scale/rgb/rgba image with height-values as heightmap, then you are mostly right.

list of Z-axis values

You can store your values however you want, you can even serialize/deserealize them, the only difference is that the image format is universal and is used in all the 3d software. So you probably want to make your pipeline based on the image heightmap format since you probably won't generate heightmaps procedurally yourself and will import them from some kind of 3d-software.

3D model

Heightmaps can be used only when f(x,z) has got one value. In this case I believe there's no reason to use 3d meshes instead of heightmaps.

Does it depend on the detail of the terrain or is it just more efficient to use a heightmap?

No, LOD and other stuff depends only on your implementation. It's just that in heightmaps you use 8 bits(grayscale) / 24 bits(RGB) / 32 bits(RGBA) per vertex and with 3d model you use 3x32 bits per vertex.

So, basically, heightmaps are used just to save some memory / importing expanses. And they are probably easier to generate, but I am not a 3d modeler so can't say for sure.