Home / Legacy / Lesson 1: Working with the Unity Terrain

Lesson 1: Working with the Unity Terrain

/
/
/
642 Views
This entry is part 3 of 15 in the series Unity 3d Fundamentals Course

In this first lesson of the Unity 3d Fundamentals Series we will start by creating the Terrain for our main scene using the Unity Terrain Engine.

Lesson Outline

  • Create the Terrain;
  • Model the Terrain;
  • Decorate the Terrain
  • Add a Skybox.

Create the Unity Terrain

Just like every other entity in our scene, a Terrain is just a GameObject with a Terrain Component attached. Create a new Unity Terrain by using the Hierarchy View Create Menu.

Create a new Terrain
Hierachy + Create + Terrain

The first thing I advise you to do is to change the terrain size. By default it is quite large and in this example we just a need a very small terrain for our scene.

Adjust the terrain size to the following values:

  1. Width: 100
  2. Length: 100
  3. Height: 50

You should change this values right at the beginning because changing them later will erase all terrain editing you made

Change Terrain Dimensions
Change Terrain Dimensions

Model the Unity Terrain

Change to Layout Tall to have a better view while modelling the terrain

Change the layout to Tall Mode
Change the layout to Tall Mode

Now that you have your terrain with the right dimensions, it is time to start modelling.

The Unity  Terrain Engine has three tools that allow us to model our terrain:

  • Raise/Lower Tool;
  • Paint Height Tool;
  • Smooth Height Tool.

Raise/Lower Tool

How to use:

  • LMB to Raise

  • LMB + SHIFT to Lower

 The opacity value defines the strength of your brush when raising or lowering the terrain.

Terrain Raise Tool Example

I usually decrease this value approximately to 30 because higher values make the effect quite exaggerated.

When working with smaller opacity values you may need to paint several times over the same area in order to get start having effects.  But I prefer this way because we have a better control over the result.

2_2

I also like to apply a small noise effect to all terrain area to get rid of the completely flat areas.

2_3

Don’t worry about pointy spikes on you terrain because we will smooth it later

2_4

Smooth Height Tool

How to use:

  • LMB to Smooth

When working with the Raise/Lower tool you will see that eventually your terrain will start to create some pointy areas. Unless this is what you are looking for you can use the smooth tool to correct those areas.

2_5

I always work with the smooth tool with the maximum opacity. 2_7To apply the smooth to an area of your terrain you need to click and hold and just keep moving the brush on the same area until you reach the desired effect.

I usually also apply the smooth to the noise effect in order to get a non–flat but smoothed terrain.

Paint Height Tool

The paint effect allows you to raise or lower your terrain to a specific height by clamping the terrain at the value defined in the Height property.

2_8

You can also change the overall height of the terrain by using the Flatten button. This is quite useful when you want to lower some areas of your terrain to create lakes or rivers for example.

 

Decorate the Unity Terrain

When you are done modelling your terrain it is time to start decorating it. You have three options when decorating your terrain:

  • Paint Texture;
  • Place Trees;
  • Paint Details.

I advise you importing some packages from the store in order to have more assets to choose from. To this project I imported the following packages (all from Unity Technologies): Terrain Assets; Shanty Town Trees; Shanty Town: Brush Vegetation

Paint Texture

To start painting your terrain, first you need to add the texture you will be using.

3_4

When adding a new texturing we have two slots to assign textures. We will only be using the Texture one. The one for the Normal Map does not work with the default terrain shader and we will not be covering this on this lesson.

3_5

When choosing the texture you may want to filter the results by searching for the texture name.

3_6

The first texture you add will be applied to all terrain. You can edit the size of the texture by changing the tile property. I usually like to work with tile values around 10-15.

3_8

Decreasing the tiling size will make the texture much smaller and to repeat more times.

Decreasing the tiling size will make the texture much smaller and to repeat more times.

Increasing the size will make each tile much bigger and to repeat less times.

Increasing the size will make each tile much bigger and to repeat less times.

We need to have several textures in order to get a better looking terrain. So add some more textures to the Paint Texture tool.

How to use:

  • LMB to Paint

The terrain textures work as layers. When painting with more than one texture we will need to adjust the opacity effect in order to get more or less blending.

3_12

The Opacity level controls the strength of our brush when painting the new texture. The higher the value, the quicker the texture reaches the full opacity.

We can control the maximum value of opacity by changing the Target Strength. If equals 1 the new texture will be completely opaque and so no blending effect.

Keep painting and messing with the values until you reach the desired effect.

3_14

Place Trees

The Unity Terrain Engine allows to easily place tree models on the terrain. Just like in the Paint Texture Tool, we first need to add the tree models that we are going to use.

3_15

Then we need to select the tree from our assets list. On the Add Tree dialog we can adjust the Bend Factor for the tree. This will set how much the tree is able to bend when reacting to the wind.

3_16

When choosing a tree model you may want to filter the results by searching for the tree name.

3_17

We are going to add some more trees. In this project I have imported the following trees:

  • Tree Acacia A;
  • Tree Acacia B;
  • Small Savanna A;
  • Small Savanna B;

Now that we have set our tree library, we have two options to place the trees on the terrain: Mass Place Trees or the manual way.

The Mass Place Trees is an automated process. We just need to define the number of trees that we want to place and it randomly place trees on the terrain using the ones from our tree library.

3_18

This method is great to place trees all over your terrain without any hassle.

3_19

However you cannot control where the trees are placed or the amount of each tree that is being used. But to be honest I usually like to start with this one and then adjust the trees using the manual process.

How to use:

  • LMB to place trees;

  • LMB + SHIFT to erase trees;

  • LMB + CTRL to erase only the selected tree type;

3_20

We have several options to control how to manually place the trees:

  • Brush Size: Area to place;
  • Tree Density: Adjust the amount of trees to place on the area;
  • Color Variation: Randomly changes the tree color to create some diversity;
  • Tree Height and Width: Adjust the overall size of tree. 100 is the original tree model size;
  • Height and Width Variation: Randomly scale the tree inside the interval (e.g. [Tree Height – Variation; Tree Height + Variation]);

Using the manual process we can add and remove trees until we reach what we are looking for.

3_21

Paint Details

I am not using the paint details tool on this project so I will just jump over it. But if you are interested in knowing more about this tool check here.

To be honest I usually don’t get along with this tool. What I end up doing is adding the grass and weed meshes to the trees section and just painting it like a regular tree. I prefer but I think it decreases performance

3_22

Add a Skybox

I usually adjust my directional light color to something different than pure white. In this case I will adjust it to a more warm color

4_1

Now that we have our Terrain we need to add a Skybox to make our scene more realistic. First we are going to import the Skyboxes package provided with Unity3d.

4_2

After importing all assets inside the package we need to select and apply a Skybox to our scene. First we will open the Project Render Settings.

4_3

Then we drag our skybox  material into the Skybox Material slot or just press browse.

4_4

While choosing the skybox we can filter the results by searching for the material name. In this case we will try with sky.

4_5

And we are done. Our terrain is completed and the skybox is in place.

4_6

What’s next…

On the next lesson we will create the setup for our First Person Controller Weapon.

Series Navigation<< Unity 3d Fundamental ConceptsLesson 2: Create the First Person Weapon >>

6 Comments

Leave a Comment

Your email address will not be published. Required fields are marked *