home // text // multi-media // misc // info

[ video-games game-design unity ]

GIMP and the Unity terrain system

I’m 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 will understand.

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

First off, I searched for “usgs heightmaps” in Google Image Search and found the following image, which I opened in GIMP:

USGS data open in GIMP

I cropped and resized the 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, I chose File -> Export…, and exported the image as a .raw file:

Exporting a GIMP RAW image, part 1

Note that “Raw image data” is selected in the file type selection box. When you hit Export, set the following options:

Exporting a GIMP RAW image, part 2

Your image should be saved in the appropriate format.

Next, open your project in Unity, and add a Terrain to the scene (I’m assuming you’ve done that already, and don’t need my help). 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:

Unity RAW import settings

Yoda willing, that should just about cover it, and your terrain should look terrainy:

USGS terrain, open in Unity