I've been pondering this question awhile now... many 3d engines support advanced terrain rendering using quadtrees, LOD... all the features you expect. But every engine I've seen loads height data from heightmaps... grayscale bitmaps. I just can't understand how this is useful - each point in a heightmap can have one of 256 values. But what if you wanted to model Mt. Everest? with detail of 1 meter, or even greater? That's far outside the range of 256. Of course I understand that you can implement your own terrain format to achieve this, but I just can't see why heightmaps are so widely used despite their great limitations.
-
4using all four color channels gives you 32bit of precision or ~4billion distinct height values – Dave O. Jun 11 '10 at 23:13
6 Answers
Heightmaps are very lightweight, very fast to load, and can be generated procedurally fairly easily. They also use quite a small footprint for memory.
They're used a lot because they're easy and fast, and handle many scenarios well. That being said, they're not useful for every scenario, and not a fully generalized terrain format.

- 554,122
- 78
- 1,158
- 1,373
-
and they can be loaded using the image handling code you've already included in your 3d application. You don't need to include more code to load another data format – Jay Jun 10 '10 at 22:43
From a viewpoint of displaying graphics, the greatest precision that normally matters is (in simple terms) a single pixel in the final display1. Given the resolution of a typical current monitor, having another couple or three bits for the height map would be nice -- but for most geometry, it's not really necessary. In particular, even though a single pixel pretty much defines the greatest precision for which you have a lot of use, drawing Mt. Everest so its height is actually wrong by two or three pixels isn't really a major problem for most people most of the time.
It comes down to this: the idea that you'd want to use a precision of one meter for a height map of Mt. Everest is simply a mistake -- a need (or even use) for that level of precision is right on the border between rare and nonexistent. At the same time, using a relatively dense format like one byte per pixel generally means quite a bit -- less storage and less bandwidth leading to faster displays.
- Technically with anti-aliasing, sub-pixel resolution can and does mean something -- but while it matters a lot for things like smoothing lines that would otherwise look quite jagged, for something like getting the height of a mountain correct, it doesn't mean nearly so much. In fact, as far as most people care most of the time, it's completely meaningless.

- 476,176
- 80
- 629
- 1,111
-
I hope you don't mind I comment on this 4 year old post. But I got a small question and don't think it's worth an own post. So, why not put these height details in the model itself? Why should we create a heightmap which has to be assigned first? – Andy Mar 20 '14 at 10:40
-
@Andy: Mostly for speed. The height map is basically taking the heights from the mesh, and turning it into a very dense format by itself, so you don't need to look through all the other mesh data to get to the heights. – Jerry Coffin Mar 20 '14 at 16:14
Heightmap Pros:
- Look like real terrain from a distance.
- Very easy to compute height at any x, y assuming z is up. This is useful for moving players, collision detection, and physics.
- Easy to edit in a paint program.
Heightmap Cons:
- Use memory inefficiently when there are large flat areas (constant height).
- Use rendering hardware inefficiently when there are large flat areas.
- Can't represent steep or overhanging terrains.
- Can only represent square areas.

- 1,127
- 6
- 7
-
What sort of structure would you use to represent steep or overhanging terrains? – Jake Petroules Jun 10 '10 at 22:30
-
The game will undoubtedly have the ability to render arbitrary triangle meshes for characters, vehicles, and structures. Arbitrary terrain meshes can be embedded into the heightfield in the same way. – bbudge Jun 11 '10 at 00:28
But what if you wanted to model Mt. Everest?
You'd use something else. Clearly, if every engine you've encountered uses heightmaps, it works just fine for them. No need to overcomplicate things if the simple solution works for you.

- 176,543
- 40
- 303
- 368
Another plus with heightmaps is that in general it avoids the overhang issue which makes aspects of physics and movement harder. But even with a hightmap, you can have other geometry that could create overhangs.
Also, texturing can be simpler as long as the height doesn't vary too much causing stretching.

- 4,395
- 1
- 23
- 24
Heightmaps have the advantage that has direct hardware support (texturing), and it can be draw using existing painting tools (even specialized).
Of course, depending on the format of the information stored in the heightmap, some rendering doesn't looks like it should be, but because heightmaps are actually used in the wrong situation.
As enhancement, heightmap pixels could be stored in a 16 bit floating number (half float) or a 32 bit float, allowing to have higher ranges and precision allowed with an 8 bit pixel with fixed precision.

- 11,646
- 11
- 70
- 125