{{short description|Type of raster image in computer graphics}} {{about|modifying the geometry of surfaces - or the illusion of this - in computer graphics|techniques which relate to recording distances from a viewpoint|depth map}} {{More citations needed|article|date=December 2009}} [[Image:Heightmap.png|thumb|right|200px|A heightmap created with [[Terragen]]]] [[Image:Heightmap rendered.png|thumb|right|200px|The same heightmap converted to a [[Polygon mesh|3D mesh]] and rendered with [[Anim8or]]]]
In [[computer graphics]], a '''heightmap''' or '''heightfield''' is a [[raster graphics|raster image]] used mainly as [[Discrete Global Grid]] in [[digital elevation model#Types_of_DEM|secondary elevation modeling]]. Each pixel stores 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 (digital image)|channel]] interpreted as a distance of [[displacement (vector)|displacement]] or "height" from the "floor" of a surface and sometimes [[Visualization (computer graphics)|visualized]] as [[Luma (video)|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 format]]s 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 a 24-bit image, 256<sup>3</sup> = 16,777,216 heights can be represented (256<sup>4</sup> = 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.
[[File:World elevation map.png|thumb|360px|Height map of planet earth at 2km per pixel, including oceanic bathymetry information, normalized as 8-bit grayscale]] Heightmaps are commonly used in [[geographic information system]]s, where they are called [[digital elevation model]]s.
== Creation == Heightmaps can be created by hand with a classical paint program or a special terrain editor. These editors visualize the terrain in 3D and allow the user to modify the surface. Normally there are tools to raise, lower, smooth or erode the terrain. Another way to create a terrain is to use a terrain generation algorithm. This can be for example a 2D [[simplex noise]] function <ref>Artificial Terrain Generation</ref> or by [[diffusion-limited aggregation]].<ref>[http://voxels.blogspot.de/2014/01/procedural-terrain-heightmap-generation.html DLA based Terrains]</ref> Another method is to [[3D reconstruction|reconstruct]] heightmaps from real world data, for example using [[synthetic aperture radar]].<ref>Kirscht, Martin, and Carsten Rinke. [https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.54.1157&rep=rep1&type=pdf "3D Reconstruction of Buildings and Vegetation from Synthetic Aperture Radar (SAR) Images."] MVA. 1998.</ref>
== Use == Heightmaps are widely used in [[terrain rendering]] software and modern [[video game]]s. Heightmaps are an ideal way to store digital terrain elevations; compared to a regular polygonal mesh, they require substantially less memory for a given level of detail. Most modern 3D computer modelling programs are capable of using data from heightmaps in the form of [[bump mapping|bump]], [[normal mapping|normal]], or [[displacement mapping|displacement]] maps to quickly and precisely create complex terrain and other surfaces.
In the earliest games using software rendering, the elements often represented heights of columns of [[voxel]]s rendered with [[ray casting]]. In most newer games, the elements represent the height coordinate of [[polygon mesh|polygons in a mesh]].
=== Rendering software === * [[Terragen]] – terrain renderer * [[Picogen]] – terrain renderer and heightmap creation tool * Materialize – Free PBR ([[physically based rendering|Physically Based Rendering]]) creation tool
=== Generating software === {{main|Scenery generator#Software}}
=== Trivia === Although the terms heightmap and heightfield are often indistinguishable from each other, there is still a small difference in the terms. Heightmap comes from the mathematical term 'map' and heightfield comes from the mathematical term 'vector field'. Heightmap is the more correct description because most heightfields are not a (vector) field in mathematical terms but they are always a map (in mathematical terms as well as in the visual representation).
==See also== *[[3D scanner]] *[[Digital elevation model]] *[[Draw distance]] *[[Range imaging]] *[[Texture splatting]]
== References == <references />
== External links == * [http://www.povray.org/documentation/view/3.6.1/279/ POV-Ray : Documentation : 2.4.1.5 Height Field] * [https://3dgrayscale.com/what-is-a-3d-heightmap/ :3DGrayscale - Understanding 3D Heightmaps ] [[Category:Computer graphics data structures]] [[Category:Digital elevation models]]