- Unity Packages: Terrain Tools
- This section delves into terrain creation using the Terrain Tools plugin.
- Examples of terrain building:
- Traditional game maps (Sykrim, GTA, Guild Wars): comparison
- Unconventional game world: Outer Wilds
- Terrain generation:
- Experimental:
- To install the plugin, navigate to the top menu bar and select Window > Package Manager.
- In the Package Manager window, select Packages: Unity Registry, and search "terrain".
- Install Terrain Tools.
Terrain
- To create new terrain:
- Navigate to the top menu bar: Window > Terrain > Terrain Toolbox.
- In the "Create New Terrain" tab, click on the "Create" button.
- Create a cube to serve as a spawn platform for the Player (instead of the previous plane), then adjust the positioning of the Player and Main Camera GameObjects so they are above the cube.
- While the Terrain GameObject is selected, you'll find (in the Inspector) the "Terrain" component with five tabs: "Create Neighbor Terrains", "Paint Terrain", "Paint Trees", "Paint Details", and "Terrain Settings".
- In the "Terrain Settings" tab:
- Set Terrain Width and Length to 200 in the "Mesh Resolution" section.
- If additional terrain sections are required:
- Access the "Create Neighbor Terrains" tab.
- Click on neighboring regions around the current terrain in the scene (so terrain is all around the player spawn point).
- Ensure each terrain section is set to the "Ground" layer to enable raycast for crosshair positioning to interact with the terrain.
- In the "Paint Terrain" tab:
- Choose "Raise or Lower Terrain" from the drop-down menu.
- Select a brush and adjust Brush Strength and Size as needed.
- Sculpt the terrain to create hills or other features.
- To add high-frequency details, we can use the Sculpt/Noise option (instead of the "Raise or Lower Terrain" option in the "Paint Terrain" tab).
- In the inspector, set up the Noise Height Tool Settings. Try:
- Test different noise types (Noise Type field in the terrain component, under Domain Settings).
- Zoom in and out the Noise Field Preview (to change the scale of the noise).
- Test different values in Domain Settings.
Terrain Heightmap
- Utilizing a texture as a heightmap allows us to determine the elevation of terrain points based on the values within the texture:
- Begin by acquiring a suitable texture:
- We can generate a noise texture via: Window > Terrain > Edit Noise.
- Export the generated noise as a texture using the option located at the bottom of the window.
- Next, proceed to create a new terrain:
- Access the Terrain Toolbox from the top menu bar: Window > Terrain > Terrain Toolbox.
- Activate the "Import Heightmap" feature.
- Select the desired texture to be used as the heightmap.
Terrain Texturing
- Aim to create a terrain that resembles a moon or barren planet, with sandy ground and rocky areas.
- Get two textures: one for the sandy ground and the other for rocky regions from Poly Haven.
- Import the textures into the Unity project under Assets/Textures.
- In the Inspector for the terrain, go to the Paint Terrain tab and choose "Paint Texture" from the drop-down menu.
- Under the Terrain component, create a new layer called "Sand" and assign the sandy texture.
- Open the created layer in the Inspector (double click on "Sand" in the Layer Palette list, or click on the created file for that layer in Assets folder):
- Set size for X and Y to a bigger number (try 20).
- Set the normal map (to the texture with "nor" in its filename).
- Select that normal map from the asset folder and set Texture Type to "Normal map" (in Inspector).
- Repeat the process for rocky areas, creating a new layer and assigning the rocky texture.
- If the Layer Palette list is buggy, remove both layers and add the created layers (from Assets folder) as needed.
- Select the rocky layer and paint the terrain for rocky areas.
- You can use Brush Mask to automatically paint flatter terrain with sand texture:
- Create a new Brush Mask (in the Terrain component > Brush Mask section > "+" Slope).
- Select the Sand layer and paint over the rocky areas (use large Brush Size).
The final state should look something like this:
