Terrain
A Terrain is a console tool for creating a Unigine-native terrain from a height map, and vice versa. (Created terrain objects can be loaded into the engine via the Load option.)
To invoke Terrain tool, run terrain_x86.exe (in Windows) or terrain_x86 (in Linux) from a command-line console (the 64-bit version has x64 postfix).
Command Line Options
A Terrain tool recognizes the following command line options:
- -o NAME — name of the output file.
- -n NAME — name of the output normal map. It is created from a height map to illuminate the terrain.
- -s STEP — step for the terrain grid. The default is 1 unit.
- -h HEIGHT — maximum height of the terrain. The default is 1 unit. (Make sure that you set this value as low as possible.)
- -d DISTANCE — distance to the first LOD tile of the terrain. The default is infinity (no optimization).
- -t THRESHOLD — flatness threshold to optimize rendering of flat areas of the terrain. The default is 0 (no optimization).
Input and Output Formats
All mesh formats that can be converted into Unigine meshes are supported. A list of such formats is available here: Supported File Formats.
The following output formats are supported:
- Portable Network Graphics (PNG)
- PhotoShop Document (PSD)
- Direct Draw Surface (DDS)
The height map needs to be of a power-of-two + 1 size (such as 257 × 257 or 513 × 1025). The possible formats are the following:
- R8 - a simple height map with 256 height gradations.
- R16 - a height map with 65536 height gradations.
- RG8 - a height map with 65536 height gradations.
The height map can have the following extensions:
- Direct Draw Surface (DDS)
- Targa (TGA)
- Portable Network Graphics (PNG)
- PhotoShop Document (PSD)
- Portable pixmap format (PPM)
- Portable graymap format (PGM)
- JPEG (JPG)
Usage
On Windows the syntax would be:
- To create a terrain from the height map:
terrain_x86.exe heightmap.png -o terrain_name.ter
- To create a height map from the terrain object:
terrain_x86.exe terrain_name.ter -o heightmap.png
On Linux and Mac OS X the syntax would be:
- To create a terrain from the height map:
terrain_x86 heightmap.png -o terrain_name.ter
- To create a height map from the terrain object:
terrain_x86 terrain_name.ter -o heightmap.png
Step-by-Step Example for Windows
To create a terrain object form a height map, you need to do the following:
- Open the command-line console. For that, click Start→>Run and type cmd. Click OK.
- Specify a tool to be run. For Windows, it would be:
terrain_x86.exe
- Specify a hight map from which the terrain will be created.
terrain_x86.exe "D:\Raw\heightmap.tga"
- Specify a name and path to the created terrain.
terrain_x86.exe "D:\Raw\heightmap.tga" -o "D:\UnigineSDK\data\my_terrain.ter"
- Specify a name of the normal map to light the terrain.
terrain_x86.exe "D:\Raw\heightmap.tga" -o "D:\UnigineSDK\data\my_terrain.ter" -n "D:\UnigineSDK\data\normal_n.dds"
- Now we need to specify terrain options. For example, set the grid step to 0.5 units.
terrain_x86.exe "D:\Raw\heightmap.tga" -o "D:\UnigineSDK\data\my_terrain.ter" -n "D:\UnigineSDK\data\normal_n.dds" -s 0.5
- Set the maximum height your terrain has. For example, 70 meters.
terrain_x86.exe "D:\Raw\heightmap.tga" -o "D:\UnigineSDK\data\my_terrain.ter" -n "D:\UnigineSDK\data\normal_n.dds" -s 0.5 -h 70