Height Maps - jgoffeney/Cesium4Unreal GitHub Wiki

Back

References

Formats

The default format is a 16 bit PNG.

TerreSculptor

TerreSculptor is a free tool to convert elevation data to the Unreal Engine heightmap format.

Creating 16 bit PNG

  • Import the Geotiff
    • File->Import Terrain
    • Select geotiff format
  • (Optional) Open Terrain Properties
    • Fiddle with settings to get an idea of how it will look in Unreal (does not alter actual data)
    • Set XZ and Y spacing to 100.

TerrainProperties

  • Export to PNG
    • File->Export Terrain
    • Select PNG image format (not the old codec version).
    • NOTE: Unreal uses a specific naming scheme to indicate a heightmap is being used as a tile. If you are not using tiling then don't use an 'x' with numbers on both sides (such as to indicate resolution like myHeightMap4033x4033) because Unreal will have an error on importing the file into a landscape.

GDAL

The GDAL Translate method can convert a Geotiff to a 16-bit PNG. The key is you need to get the actual minimum and maximum elevation values to scale over. This produces the same output as TerreSculptor.

ds = gdal.Open(dtmInputFilePath)
minMaxValue = ds.GetRasterBand(1).ComputeRasterMinMax()
ds = gdal.Translate(pngOutputFilePath, ds, format="PNG", scaleParams=[minMaxValue[0], minMaxValue[1], 0, 65535](/jgoffeney/Cesium4Unreal/wiki/minMaxValue[0],-minMaxValue[1],-0,-65535) , outputType=gdal.GDT_UInt16)
ds = None

If you are creating several tiles then you want to use the same min and max elevation values for the entire region so they align properly when importing in Unreal. Note that a 16-bit PNG uses 9-bits to store the elevation data so the larger the elevation range the more precision you will lose in the conversion.

Landscape Sizes

The Unreal documentation gives suggestions for landscape sizes. It performs an automatic division of the data into sections and components and certain image dimensions maximize the are while minimizing the Landscape components. The default expectation is a resolution of 1 meter per pixel and a maximum size of 8129x8129. Larger landscapes can be created using World Partition. If you use one of the recommended dimensions for the height maps then it will automatically know the correct number of sections and components.

Z Scale

In a 16-bit greyscale PNG the elevation values are stored in 9 bits (or 512 values). When importing the 16 bit PNG height map you need to do the following:

  • range(cm) = maxHeight(cm) - minHeight(cm)
  • ZScale = range(cm) / 512.0

My elevation data had a range of 6817 cm so it requires a Z scale value of 13.31445. For 1 meter data you only need to alter the Z scale value. Other with you would alter the X and Y scale values to match the resolution in cm. For example half meter resolution data would have X and Y scale values of 50.

ImportHeightMap