Creating Terrain, Deco Layers, and Material Layers
This recipe covers the basics of adding a Terrain to your scene, and shows how StaticMesh actors can be distributed over its surface. We also look at brushes that can touch up the HeightMap to support meshes on the deco layer, and then improve the look of the terrain's surface by adding decals. We don't cover everything involved in terrain editing, since you can probably make your own inroads after doing this example. Also, the Terrain tool is somewhat overshadowed by the newer Landscape tool, and its accompanying addition Foliage which takes over the role of Deco Layers. Still, both tools are powerful. A terrain can even be converted into a landscape later on.
How to do it...
- Create a new Blank Map and go to the main menu and choose Tools | New Terrain. Give it dimensions of
32 x 32
. - In the Content Browser, highlight the Material M_ASC_Floor_BSP_Tile01.
- Enter Terrain Editing Mode (Shift + 3). Right-click in the space below the HeightMap layer then choose New Terrain Setup Layer from Material (select package).
- Assign the package to one of your own, and the Group to TLM.
- Assets will be created in the chosen package and group, as shown in the next screenshot. This differs from the approach of the Landscape tool, which is discussed in the next recipe.
- Next highlight the Material in the Content Browser called Packt.Material.M_Wet. Create another terrain Material layer as before.
- With the Paint brush, mask out the top Material (hold down Ctrl + LMB when brushing on the terrain). Also, don't forget to set strength and radius for the brush first. To invert the paint direction, hold Ctrl + RMB while brushing.
- The brush settings for the Terrain Editor are distributed across the Tool, Settings, and Brush sections of the Terrain Editor. Since the Paint tool is highlighted by default, all that's required to get ready to paint is to adjust the brush Strength slider and also adjust the Radius and Falloff sliders. Falloff creates a decay from the brush radius outward. If you like, you can turn on symmetry for the brush using the Mirror option there too. Below the Mirror tool there are some brush shape presets that automatically set Radius and Falloff values. You can adjust Falloff by holding Ctrl and scrolling the mouse wheel. You can adjust Radius by holding Alt and scrolling the mouse wheel. The brushes in the tools set can be explored easily by holding the cursor over their icon and reading the tooltip.
- You can only add so many Material layers to a terrain before it overloads. Instead, you can try using decals to add complexity. Set your Content Browser filter to include Material Instance Constant and search for BloodSplatter. Then right-click above the ground in the viewport and choose Add Decal: CH_Gibs.Decals.BloodSplatter.
- You can scale up the decal by opening its properties (F4) and adjusting Decal Actor Base | Decal | Decal | Width and Height. Make it
2048 x 2048
. - The decal is placed off a gray circle icon [ ]. This can be scaled directly. In Move mode, Alt + drag it to make a copy, and rotate it to a different angle relative to the first, just to make a more spread out looking splatter on the ground.
- Enter Terrain Editing mode again (Shift + 3). Select the HeightMap layer and use the Paint brush with Ctrl + RMB to depress the surface a little.
- Enter wireframe mode (Alt + 2) and you'll notice the terrain doesn't have a lot of geometry detail. You can add more detail by editing the properties of the terrain (F4) and raising the MIN and MAX Tessellation Level to 16 and the Editor Tessellation Level to 16. The same result can be achieved in the Terrain Editor during Terrain Editing mode by clicking on the icons in the Tessellation section to Increase or Decrease the geometry detail.
- Create a light, raise it up in the space above the ground, and right-click on it and choose Convert Light | Directional Lights | Dominant Directional Light. This effectively adds a sun to the scene. Rotate this sun to an angle facing three quarters downward to the ground (it has a little blue directional arrow). If you want, tint it slightly yellow in its properties. Also, open its Light | Light Component | Light Component | Shadow Filter Quality and set this to SFQ_High.
- Now let's add a Deco Layer to sprinkle some plants on the terrain. For the depression in the ground, choose the StaticMesh in the Content Browser called S_CloverPlant_01 and in the Terrain Editor right-click under the layers already added and choose New Deco Layer.
- With the terrain object selected in the viewport, press F4 and go to the Terrain | Layers | Deco Layers roll out. Expand it and click on the add entry icon [ ] on the Decorations channel. This will add an empty factory, with two options. Use the blue downward triangle [ ] to choose StaticMeshComponentFactory.
- Expand the Factory settings to reveal the Static Mesh entry, and click on its assign icon [ ]. This will add the mesh that was selected in the Content Browser.
- Change the Density property (below the factory settings) to 1. Otherwise, the default value may be too low to actually see any meshes added on the terrain.
- Lock this set of properties using the little padlock icon [ ] at the top of the properties window. This keeps them present in the view no matter what other object you may choose. Ordinarily, changing from object to object updates the properties panel to show the current selection's properties.
- Make sure the Plant Deco Layer is highlighted in the Terrain Editor and use the Paint brush (with Ctrl held down and a fairly large brush radius), to brush plants into the hole in the ground. When you paint , if you don't see plant meshes, increase the Density property until you do.
- Set a Slope Rotation Blend of about 1 so plants on angled polygons will tilt instead of standing vertically, as shown in the following screenshot:
- Notice the decals we applied to the terrain also effect the plants, which are StaticMesh actors. This looks strange, so select the decals, press F4, then turn off their property: Decal Actor Base | Decal | Decal | Project on Static Meshes. Individual actors also have a property Static Mesh Actor | Static Mesh Component | Rendering | Accepts Static Decals, which you can turn off if you don't want them to receive a decal.
- You can continue adding Deco Layer entries to add pebbles, trees, grass, or other repeatable objects. You can see in the next screenshot that the properties for the plants spread across the ground are supplied by Deco Layer [0] | Decorations | [0] | Factory, which is expanded out to show the StaticMesh asset used, the Density value of 100, the Min Scale and Max Scale factor, and the Slope value which helps the plants orient on the surface of the terrain. Build All to see the lit result.
There's more...
A Heightmap is a texture that uses variance in black and white tones to depict altitude, where white is more and black is less.
The newer Landscape tool covered in the next recipe can handle .raw
and .r16
heightmaps. The Terrain Editing Mode dialog includes an Export Heightmap section, shown below, which sends out a G16MPT3D
file, a .BMP essentially, which you can open and convert using an external utility like HMCS (Heightmap Conversion Software); this is discussed in the next recipe too. In this utility you can resample the size of the image and also adjust the altitude value for the black and white intensity.