Using GIMP heightmaps in Unity

Originally posted on 24 July 2013 as
GIMP and the Unity terrain system
The current version has been modified for clarity.

I’d been working on a small jam project in Unity, for the purposes of which I needed/wanted to import a greyscale heightmap into Unity’s reasonably-okay terrain system. Strangely, Unity only accepts .raw files as heightmaps, and I wasn’t able to find a satisfactory explanation online of how to export from the GIMP in a format that Unity would understand.

After a small amount of fiddling, I got it to work, so I’m writing down the process here, for posterity and glamour.

A quick search for “usgs heightmaps” will get you any number of good sample images to open in GIMP.

First, crop and resize your image — note that your heightmap dimensions must be a power-of-two plus one, or 33x33, 65x65, 129x129, 257x257, 513x513, &c…

Next, from the GIMP, choose File -> Export…, and export the image as .raw:

Note that “Raw image data” is selected in the file type selection box.

When you hit Export, set the following options:

Your image should be saved in the appropriate format.

Next, open your project in Unity, and add a Terrain to the scene. To import our newly-created .raw file, go to the Terrain settings and hit “Import Raw…”

Use the following settings in the “Import Heightmap” dialogue:

That should just about cover it, and your terrain should look nice and terrainful: