1.9. CREATING A LANDSCAPE IN UE4
This section’s all about how to use the data we’ve just prepared to create a landscape in UE4.
The first thing we need to do is create a new project:
- Lauch the Unreal Engine from within the Unreal Browser.
- On the ‘New Project’ tab, select the ‘Blank’ Blueprint.
- Select ‘Desktop/Console’ and ‘Maximum Quality’.
- We don’t need any starter content, so set ‘No Start Content’.
- Navigate to the folder you want to create your project in and give it a suitable name.
Make the GIS data available to the project:
- Copy the exported files into the new project’s folder structure:
Add the procedural landscape plugin to the project.
- To do this you need to close the project you’ve just created and return to the Unreal Browser.
- Click ‘Add to Project’ on the Procedural Landscape Ecosystem.
- Select the Project to add the content to.
- Click ‘Add To Project’
Launch the project again and delete the default ‘Floor’ object.
- Select the ‘Floor’ object in the ‘World Outliner’.
- <Right-click>, select ‘Edit’ > ‘Delete’
Create a new landscape and import the height map:
- Select ‘Landscape’ mode from the ‘Modes’ tool bar.
- Under ‘New Landscape’ select ‘Import from File’
- Click the file browser button next to the ‘Heightmap File’ field.
- Navigate to your source data folder and select the .png heightmap you created.
- Click ‘Open’.
Apply the procedural landscape material:
- Navigate to the Procedural Landscape Ecosystem folder that contains the landscape materials.
- Select ‘M_Spring’ and drag it into the landscape material slot.
Next we need to set the scale values to the landscape, so here follows a little maths:
- X and Y scales are easy. We’re using 1m/pixel source data, so we want the scale to be 100 in each of these fields. (UE4’s default units are cm.)
- Per the Unreal documentation, ‘Z-Scale’ = 100 gives a range -256m to +256m.
- From the meta data we used to scale the DTM data to 16-bit values, we know the min and max elevations of our heightmap (382.521m and 944.927m respectively).
- The range is therefore 562.406m metres (944.927m – 382.521m).
- ‘Z-Scale’ = (Range/256) x 100 = (562.406/256) x 100 = 219.69
- Input these values in the ‘Landscape Scale’ parameters (see below).
- Now ‘Import’ the heightmap.
At this point, UE4 will import the heightmap and create our landscape.
Next we need to set the position of the landscape object origin to the correct location. UE4 specifies the origin as the upper top-left corner of the landscape, which means we need to set X and Y positions to 0, and the Z position to the maximum height of the terrain. The maximum height of our terrain is 944.927m. Since, by default, UE4 measures units in cm, this becomes 94492.7cm.
- Input the values for the landscape position into the ‘Landscape’ actor’s ‘Location’.
Assign Layer Info objects to the landscape material layers:
- In ‘Landscape’ mode, select ‘Paint’.
- Under ‘Target Layers’, you’ll find the ‘Procedural Landscape Ecosystem’ layer list. Initially, each ‘Layer’ will be blank.
- Click the drop-down arrow in the field under the ‘Grass_plane’ layer name and select ‘Grass_plane_Layerinfo’.
- Repeat this for the other layers in Procedural Landscape Ecosystem.
[NOTE: If you’re using your own landscape materials, you can mimic this step with your own assets.]
Automatic Exposure provides additional realism in game, but is a bit of a pain when working with large landscapes in the Unreal Editor – continually adjusting brightness as you navigate the scene. At this point we find it easier to fix it to a specific level:
- In the viewport, click the ‘View Mode’ (‘Lit’ by default)
- Click ‘Exposure’ and adjust as preferred.
- You might also like to adjust the intensity of the ‘Light Source’ in the ‘World Outliner’ to set the fixed brightness a little higher.