Nerd For Tech
Published in

Nerd For Tech

Getting Started with Terrain Tools in Unity Part 1: Interface and Mesh Sculpting

If you love open world games and have ever wanted to make beautiful outdoor 3D environments, this article is for you. Creating a detailed environment has never been faster or easier than now with Unity’s Terrain Tools.

Setup

Start by creating a new 3D project. You don’t need to have any particular pipeline running, but I am using the HDRP for this article. Navigate to your Project Settings>Package Manager, and make sure Enable Preview Packages is turned on.

Open your Package Manager and search for Terrain Tools. Press the Install button.

A pop-up should generate with a link button to Download Asset Samples from Asset Store. Press it.

The link will take you to the asset on the asset store. You can alternatively just go to the asset store and look for the Terrain Sample Asset Pack. Push the Add to My Assets button.

Pack in Unity in the Package Manager, the Terrain Asset Pack will be easy to find my sorting by My Assets under Packages. Press the Download button.

This will generate a preview screen where you have the option to deselect any assets you do not want to import. Press the Import button when ready.

Now the Project>Assets folder will have a new Samples folder, which contains all of the Terrain Tools Assets.

Create Terrain

Now that we are setup and ready for some heavy landscaping, generate a new Terrain in the Hierarchy by pressing the new button (+), and then selecting 3D Object>Terrain. I think you can do this without adding the Terrain Tools, but your options will be much more limited.

In the game scene I have a Directional Light that is set to Realtime. You don’t want to be baking light information while sculpting huge landscapes, so if Auto-Generate is on in your Lighting settings, turn it off. The only other things to see here are Unity’s first person controller so I can immediately run around the terrain, and the new Terrain object itself.

The Terrain object has two main components. The Terrain component houses all of the sculpting and painting tools, while the Terrain Collider is home to the physics data that let’s the player immediately begin to use the Terrain and walk freely around the world.

The new terrain is a large flat plane in the scene and game view.

The player capsule is a good reference for scale, as to how large a single piece of terrain really is.

I deleted that terrain object from the hierarchy to show a better way to create new terrain. Head to Window>Terrain>Terrain Toolbox. Here you have a lot more options you can adjust before creating the actual terrain object. For now I will keep the standard settings and press the Create button at the bottom.

Now there is a Terrain Group in the hierarchy, with a single terrain child object attached.

The assets folder will also show a corresponding file for that piece of terrain.

Select the child terrain object in the hierarchy to bring up the terrain component in the inspector, as this is where you will spend most of your time.

Create Neighbor Terrain Tool

The first icon is the create neighbor terrain tool, and it works pretty much as it is described, with some amazing additions and options.

This tool will show neighboring terrains as an outline. Simply left-click in any of the squares to create a new terrain in that location.

The new terrains will populate in the hierarchy. Feel free to parent these to an empty game object for organization.

Gear / Options Tool

The gear icon has a ton of options, most of which I won’t cover in this article. The top Grouping ID option is important, and we will come back to that shortly. The bottom area shows extensive drop downs for wind, mesh and texture resolutions, lighting and more. That’s another article just by itself!

The Brush Tool

Let’s get to the fun stuff! Press the brush icon to really get started on this terrain. If you have ever used a 2D or 3D art program, these brush shapes might make you feel at home. These brushes are all alpha channels which will be used to sculpt the landscape by using heightmap data. Basically, the white areas show the highest elevation while the black areas show the lowest. I choose the second brush to get started (round soft edge).

Under your brushes lives the Stroke options. Brush Strength, Size, Rotation and Spacing can all be adjusted here. The Jitter options will add some randomness to those values as you sculpt.

There are some easy shortcuts for these adjustments. Press and Hold the A key and move the mouse left and right to adjust the Strength of the brush.

Holding the S key will let you adjust the Size of the brush.

The D key is held down to Rotate the brush.

Navigate to Edit>Shortcuts if you want to create hot keys of your own!

Before we can sculpt hills on to the landscape, under the Brush icon, make sure Raise or Lower Terrain is selected. That’s how this whole thing works anyways. Rising the terrain based on a heightmap brush!

If you have ever used Blender or Zbrush for sculpting, you should feel at home brushing hills into the scenery. This is with a pretty low brush strength (0.046). Press and hold the left-mouse button to sculpt, and don’t forget to have fun! Press ctrl + Z to undo if you don’t like your stroke.

The game view with a player for reference is a good way to see the actual scale of those hills.

Holding the CTRL key while sculpting works in the same way as it does in other 3D modeling programs. The tool will be inversed, so the mesh will be pushed down rather than up.

Here you can see how sensitive the Strength of the brush is (0.152). It’s easy to get immediate sky scrapers with a high Strength setting. Unless you want immediate pinnacles into the heavens, keep the brush strength low.

The Spacing option will also be familiar if you have used traditional 2D art programs. A spacing of zero on a circular brush will produce a solid line, while as you increase the spacing the line will turn to dots, like pointillism.

Here is a spacing of zero on a hard edged round brush.

Let’s increase that to 50 to see the difference.

These brush strokes are more spread out with the spacing increased.

The Scatter works by adding additional brush strokes around the main path. This is very useful where lots of fast detail and texture is more important than immediate accuracy.

After the main landscape is set, use the various other brushes to get some more realistic details and shapes. This brush looks to make for some great mountain peaks.

This fluffy hillside quickly becomes a jagged and dangerous landscape.

The player might be getting worried about how much food and fire wood they have out here.

Change the Raise or Lower Terrain option to be Set Height.

There is now a Set Height Controls option. This is great if you want to clear out a plane into a mountainous landscape, but you want to control the elevation. I will leave it at zero, which will let me push the mountains back down to sea level.

A soft round brush quickly clears a plane down to the designated height!

There is also a Smooth Height option, which will average out height areas. This can be useful if you want to blend the transition between a very low and very high area.

Now switch to the Sculpt>Noise option.

The brush can now use a noise file to add quick details and textures to the environment.

The flat plane and mountains quickly become more textured without the traditional sculpting brushes.

The Sculpt>Bridge option is great for quickly adding a natural “bridge” to your landscape. There is a handy description below telling the user how to make a bridge.

Press Ctrl + left-click to set the starting point, then click to select the end point. Let Unity do the rest!

The Sculpt>Terrace option is amazing when you want a fast terraced look to your landscape.

Just click and drag to transform your landscape into a terraced landscape!

There are some handy Transform options, with Twist being one of them.

I can see how this could be used for specific game and level design reasons.

There are some amazing options for Erosion as well.

Here is an example of Thermal Erosion, as heat melts this landscape.

There is Wind Erosion, which I did not capture a Gif for…but it’s awesome.

Then there is Hydraulic Erosion, for when you want an environment that has been weathered by water.

These are some extreme examples, but hopefully you see how powerful these tools are!

Let’s revisit the Create Neighbor Terrain tool. Now that we have some height variation in our terrain, the checked Fill Heightmap Using Neighbors option will blend the height between the existing terrain and the new ones.

Here you can see it in action as I create new terrain around the central one.

You can immediately start sculpting across the boarders between terrain objects.

The reason is because by default, they all still have the same Grouping ID.

I select one terrain neighbor and change the Grouping ID to 1.

Now if I sculpt on this terrain object, the neighboring object will remain unaffected.

It’s important to remember that for best results, all terrain objects should be set to the same resolution. Terrain can be adjusted to be larger, smaller, more and less resolution, after the fact using the Mesh Resolution option. The Terrain Toolbox is perfect for adjusting the values of multiple terrains at one time!

Here is the lonely player capsule, hopefully happy that it’s on a bridge rather than at the bottom of the basin.

Press play at any time to move through the new world as the player.

Now that we have a firm grasp on creating new landscapes, please join me in my next article where I will cover adding ground textures and foliage objects to the game scene. Thanks for reading!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store