Unity tutorials

How to Make a 16-Bit Heightmap for Unity

In a Unity heightmap, each sample sets the elevation of one point on a terrain grid. This walkthrough makes a 512-metre-wide tile with a height sample every metre. You can use the same steps for a smaller test scene or a larger landscape.

Choose a resolution for your terrain

The number of samples is one greater than the number of spaces between them. For a terrain 512 metres wide, these three resolutions give different amounts of detail across the same ground.

  • 257 × 257 puts a sample every 2 metres. Use it to block out broad hills.
  • 513 × 513 gives 1 metre between samples. Use this for the walkthrough.
  • 1025 × 1025 gives half a metre between samples. Use it when smaller ridges need more definition.

Generate and export the RAW file

  1. Open the free terrain heightmap generator. Select 513 × 513 and choose Perlin for rolling hills.
  2. Adjust Scale for the size of the hills and Roughness for finer detail. Orbit the preview to inspect the slopes. Water, snow and lighting affect only the preview.
  3. Select Unity RAW (16-bit) and choose Export. Keep the resolution with the file. A headerless RAW file stores heights without recording its dimensions.

Import the heightmap into Unity Terrain

  1. Create a terrain with GameObject → 3D Object → Terrain. Select it and open the Terrain Settings gear in the Inspector.
  2. Under Texture Resolutions, choose Import Raw and select your exported file.
  3. Set width and height to 513, depth to Bit 16, and byte order to Windows (little-endian). The byte order describes the file and applies on macOS too.
  4. Under Terrain Size, use X and Z of 512 and try Y of 80. X and Z set the footprint in metres. Y sets the vertical range from the lowest possible sample to the highest.

Frequently asked questions

Why does my terrain have spikes or stripes?

Check the resolution, depth and byte order against the export. A 513 × 513 RAW file with two bytes per sample is exactly 526,338 bytes. If the size matches, check that Unity is reading it as Bit 16 with Windows byte order.

How do I fix a terrain that looks mirrored?

If a landmark that should be at the top appears at the bottom, import again with Flip Vertically toggled. Keep the original depth and resolution.

Why do the hills look like steps?

Export RAW directly from the generator. Its 16-bit samples have 65,536 possible heights. The 8-bit preview PNG has only 256, and converting that PNG to RAW later cannot restore the intermediate heights.