Create a terrain from a heightmap in Unity

With heightmaps and textures from 3D-Mapper.com you can easily create terrains for games in Unity (game engine). Prepare the heightmap and texture with Photoshop or the free image editing software GIMP. For the following tutorial we used GIMP.

 

Resources:

Get heightmap + texture from tutorial

Get Unity

Get GIMP

Prepare the images in GIMP

GIMP-place heightmap and texture in one document

1. Open the heightmap and the matching texture in GIMP. Place both images in one document.

GIMP-scale image

2. Scale the document on the shortest side to 1024 px.

Image > Scale Image

GIMP-set image canvas size

3. Set the image canvas size on the long side to 1024 px, too.  Select the section and resize it.

Image > Canvas Size …

GIMP-export texture as ong

4. Now export the texture layer as a PNG file.

File > Export as …

GIMP-change color mode to grayscale

5. Hide the texture layer and flatten the image.

Image > Flatten Image

6. Convert the image into 16 bit.

Image > Precision > 16 bit integer

7. Convert the image into grayscale.

Image > Mode > Grayscale

8. Export the image as a PNG file.

GIMP-export heightmap to data raw

8. Now export the heightmap as a data.raw file.

File > Export as …

Create a terrain in Unity

unity-create GameObject Terrain

1. Open Unity and create a new terrain.

GameObject > 3D Object > Terrain

unity-02

2. Import the heightmap (raw file).

Inspector > Terrain Settings > Import RAW

unity-03

3. Set the heightmap width and height to 1024.

 

unity-04

4. Import the texture.

Assets > Import New Asset …

unity-05

5. Create a new terrain layer.

Inspector > Paint Terrain > Edit Terrain Layers >Create Layer

unity-06

6. In Tiling Setting define the texture size for the new layer.

DONE!