-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This guide will help you to import GIS data in Unity and assumes you have FME installed and you're familiar with it (if not, check FME Home licences for free and the online tutorials Safe Software provides).
You can follow this guide with provided sample data or use your own data. There's a shapefile containing the bounding box of the project in datasource\00_perimeter\perimeter.shp
. Edit it first to get started with your own data.
- Install Unity
- Create a new project from UnityHub
- In Hierarchy, create a new 3D Object > Terrain
In order to create a terrain you'll need:
- A DEM raster
- A clean landcover vector file (no holes, no overlaps)
Unity uses a custom RAW raster file heightmap.
- Open the workbench located at
import/01_terrain/10_GEOTIFF2RAW.fmw
- Delete existing
10_terrain.raw
andRAWsettings.txt
files in the folder - Replace the GEOTIFF **_Reader _**with your own DEM
- Edit workbench published parameters:
-
min_z
: the lowest elevation your project could have -
max_z
: the highest elevation your project could reach
-
- Press play. A
10_terrain.raw
raster and aRAWsettings.txt
should appear next to your workbench - Open Unity, create a new Terrain game object
- Go to the settings of your terrain, under Texture Resolutions section, hit Import Raw... button.
- Check Flip Vertically and set the Terrain Size settings with the values found in the
RAWsettings.txt
file. - Click import. You should see the terrain now.
- Open the workbench located at
import/01_terrain/11_Splatmap.fmw
- Delete existing
11_splatmap.png
example file - Replace landcover _Reader _ with your own landcover file
- Adapt AttributeFilter to your classification attribute and values
- Press play. A
11_splatmap.png
raster should appear next to your workbench - Go back to Unity, create a folder on Project panel and name it
Editor
- Copy from this repository
unity/Assets/Editor/WorldMachine
folder into yourEditor
folder - Let Unity editor reload, a Terrain menu should appear
- In the Hierarchy panel, select your terrain, go to Inpector panel and, click Paint Terrain and select Paint Texture in the dropdown field.
- Click on Edit Terrain Layers and add at least 4 layers based on textures.
The order of terrain layers must match the colors on FME script. The order is: Red, Green, Blue, Alpha. If you're using sample data, the order of layers should be: Grass1, Asphalt, Forest, Grass2
- Now you've added all 4 layers, select your first layer in Inspector and randomly draw on terrain then File > Save
This will create a splatmap inside the terrain
- In the Project panel, click on the arrow to expand your terrain, you'll see an image named
SplatAlpha
. This is the splatmap to be replaced. - Drag and drop
11_splatmap.png
in your Assets folder - Select it and, in the Inspector check Read/Write Enabled and set Format to RGBA 32 bit.
- Go to Terrain > Replace Splatmap (from WM)
- Drag the splatmap to be replaced to the Splatmap field
- Drag
11_splatmap.png
to Newsplat field, click Replace - You should see your Terrain textured.