Heightmap
From Wikipedia, the free encyclopedia
This article is about modifying the geometry of surfaces - or the illusion of this - in computer graphics. For techniques which relate to recording distances from a viewpoint, see depth map.

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. (December 2009) (Learn how and when to remove this template message)
A heightmap created with Terragen
The same heightmap converted to a 3D mesh and rendered with Anim8or

In computer graphics, a heightmap or heightfield is a raster image used to store values, such as surface elevation data, for display in 3D computer graphics. A heightmap can be used in bump mapping to calculate where this 3D data would create shadow in a material, in displacement mapping to displace the actual geometric position of points over the textured surface, or for terrain where the heightmap is converted into a 3D mesh.

A heightmap contains one channel interpreted as a distance of displacement or “height” from the “floor” of a surface and sometimes visualized as luma of a grayscale image, with black representing minimum height and white representing maximum height. When the map is rendered, the designer can specify the amount of displacement for each unit of the height channel, which corresponds to the “contrast” of the image. Heightmaps can be stored by themselves in existing grayscale image formats, with or without specialized metadata, or in specialized file formats such as Daylon Leveller, GenesisIV and Terragen documents.

One may also exploit the use of individual color channels to increase detail. For example, a standard RGB 8-bit image can only show 256 values of grey and hence only 256 heights. By using colors, a greater number of heights can be stored (for an 24-bit image, 2563 = 16,777,216 heights can be represented (2564 = 4,294,967,296 if the alpha channel is also used)). This technique is especially useful where height varies slightly over a large area. Using only grey values, because the heights must be mapped to only 256 values, the rendered terrain appears flat, with "steps" in certain places.
Heightmap of Earth's surface (including water and ice) in equirectangular projection, normalized as 8-bit grayscale

Heightmaps are commonly used in geographic information systems, where they are called digital elevation models.
can I use heightmap into the game to make the map look real?

You can do a static image for use during narratives or as a progress map. The game-board, however, will still need to be built out of terrain tiles.

I imagine you could write a program which took height-map data and classified it into Wesnoth map tiles. Given the right remote-sensing data (or Terragen output) you might even be able to get things like desert, grass, trees and snow to be placed; but I expect the results would be highly unsatisfying and likely not very interesting to play upon.

It's not so hard to do. To Lands Unknown is a campaign that uses 3D rendered images over the terrain to achieve fairly good graphics. Look how he has done it. There is no super secret about that, I've managed to replicate it a few years ago too when trying to place an oversized tower on the map.

"There is no secret" means, "You can look at the terrain code, too." Download To Lands Unknown, play the first scenario and see if that 3D effect is close to what you want. If it is, study the terrain files and graphics. (Also, turn on Preferences->Display->Show Grid to more-easily see what the author did.) I don't know how you would use a height map though: The units have to move around in a 2D grid, so 3D rendering the background doesn't really make any sense.

Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide