Terrain Sculpting

In Unity 5

Unity has an awesome tool for creating fictional settings and it’s name is ‘terrain’.  Terrains are 3D objects that contain all sorts of things, from height map data to objects and foliage to textures.  Today, gents and ladies, we’re going to have a closer look at the terrain object.  I’ll explain how to create one and how to customize the features, so let’s get started.

First off, to create a terrain object, go to GameObject > 3D Object > Terrain.  This will create something that looks like a flat plane off center in your scene.  The plane will not have any textures yet, but we’ll fix that later.

A few side notes
  • Terrain’s come into the scene with their bottom most corner touching the origin of the scene (the middle).  Unless you want to move your camera a decent distance to a new starting point, I suggest moving the terrain to fit center in your scene.
  • Before doing this, another item of note.  Terrain’s default to 500 units by 500 units.  This number can be changed in the settings tab of the terrain’s inspector, which I’ll cover below.  Just be aware that changing the size of a terrain will throw off it’s position if you’ve already tried to center it.

Screenshot_1

The screen below is a snapshot of a terrain I created for a gaming project.  Unity offers a host of tools to paint on textures and height data, which I’ll cover in the next few images.  I just wanted to give you an idea of what a terrain might look like.

Making terrain is surprisingly quick, but to really get a feel for the sculpting process will take some time.  I will say that just because the look and feel seems off in the editor, don’t fret.  It usually looks fine while the game is playing.  You’d be surprised what good lighting, fog and sky boxes can accomplish, so always check before you dump it.

Screenshot_2

The terrain object inspector contains a host of tabs and objections.  You will notice that underneath the top label, there are 7 tabs. I’ll cover the first one, the ability to raise and lower terrain.

Before getting started on that…
  • For the terrain collider component below, there is a section called terrain data, which is drawing from an object that is in this case called Sum Valley 2.  This terrain data object is created with your terrain and holds the height data, among other things.
  • My advice, do not mess with this object, other than to rename it or move it to another folder.  Terrain’s seem to behave finicky when this object is moved from one terrain to another and you could lose all of your height map data if you try to cross terrain data from one terrain to another.
  • That said, do not copy terrains in an effort to duplicate them.  Certainly do not do this if you intend to make changes to any new copies.  Generally speaking, I would suggest that any new terrain you create should probably be done by creating a new terrain object.
  • Follow the above tips and you will save yourself a lot of headache.  Trust me.

Now, on to the big stuff.  Most of the terrain editing tools function like a Photoshop canvas.  For this tab, raise and lower terrain, you can click to raise and hold down shift to lower.  You may select a brush tool and unity has all kinds.  My favorites are the upper left and the lower rights.  I used the latter to create the rocky mountainous terrain of the image above.

You can change the brush size and opacity.  The latter essentially effects the strength of the brush.

Screenshot_3

This next tool is one I don’t use all too often, but if you need to make a road or a plateau, then this might be the one for you.  Set the height you’d like the terrain to be and this tool will press the area into the appropriate height.  Again, I’ve found this less useful than other tools.  Otherwise, the settings work the same as the previous tab.

Screenshot_4

The smooth height tool also contains similar settings, but this tool is nice because it takes the edge off.  Really, it does.  Just point and click and this tool will grind down something created with the really textured brushes until it looks like a solid bumped hill.  Changing the opacity changes the smoothing effect of the brush.

I find this tool less useful if you know what you want in the first place, but it still has it’s merits as a corrective measure and an aesthetic device.

Screenshot_5

Next, we arrive at textures.  This is the paint texture tool and it works pretty straightforward.

The opacity of the brush in this case, however, determines the alpha strength of the texture.  This means that if you wanted to sprinkle some dirt on your grass and you didn’t want to create a dirt mound, then you might want to reduce the opacity of your dirt brush when you go over the grass.

To add a texture, click on the edit textures button and add a texture from your assets.  By default, you have the option of selecting both a regular texture and a normal map.  Normal maps or bump maps allow light to bounce off of a texture, thereby giving it an element of realism and the illusion that it has more polygons than it actually has.

A word of note…

The first texture you add will cover the entire map.  Any additional textures need to be painted on with the tool.

Screenshot_6

Next, the two trickiest additions to the terrain object, trees and details.  Generally, these are the ones that breathe the most life into a terrain, so let’s take a look at them.

Tress are fairly simple.  You can add a tree prefab by going to edit trees and selecting a prefab.  I generally say to use prefabs because said game object can be fitted with a mesh collider or some kind of collision component.  A model lacks that component and you usually don’t want to walk through your trees.

A few points of note…
  • It says trees, but you can essentially place any 3D model on a terrain in this way.  Trees, rocks, houses, etc.
  • Just be aware that all objects will contain the same rotation, so maybe houses might not be the best idea.
  • You can randomize the height of your drawn trees and changing this slider will retroactively regenerate heights for trees.  You may need to save and reload your scene or debug the game before you notice the changes take effect, however.

Screenshot_7

You can paint on details in much the same way as painting on tree objects.  However, the difference between these two tools is in the physics.  Details will sway in the wind.  As such, the likely materials will be 2D grass or flowers.  Really not much else unless you’re feeling adventurous.

Adding a detail object can be done by going to edit details.  The option allows you to select a model or an image, but I would generally go with the flat 2D image.  The physics sometimes don’t work quite right on the models and it’s definitely less processing power.  You can limit the distance at which grass textures render, which is useful for performance related issues.

Screenshot_8

Finally, the last tab that looks like a cog is the settings tab.  Now, terrain objects boast a variety of internal settings, but most of these are better left as they are.

A few settings I’d like to point out, however…
  • Detail distance is the distance at which your detail rendering cuts off.  Very useful to adjust if you are experiencing performance issues.  I would first suggest reducing the amount of details you have on your terrain first, but sometimes that can’t be helped.
  • Tree distance does the same thing.
  • Terrain width, length and height are essential terrain values.  Changing the first two will impact how large your terrain is.  The height value represents the scale of height in the terrain.
  • It’s fair to say that changing these numbers will not really result in a loss of height map data … at least not much. Shrinking your terrain will only squeeze your height map data closer together.  This can be good or bad, depending on how you have things set up, but if you find your walk ways too large for your character models, it may be a viable option.

Screenshot_9

That’s all I have for now.  Check back in later for the next tutorial!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s