How to create Terrain in Unity using GAIA – Tutorial (Part 1)
So, how do we create terrain in Unity? I think we can all agree that Terrain creation in Unity is a bit lacking. So because of that we have to use some external tools. For me that is totally fine because those external tools are actually pretty advanced. In today’s article we are going to look how we can create terrain in Unity using GAIA!
In this first tutorial I will show you how you can create a randomized terrain. In the second part of the tutorial I will show you some of Gaia’s tools that will help you manually create a terrain.
This is a terrain that I created in about 10 minutes using GAIA. I’m also using the AQUAS Water System in this screenshot.
So what exactly is GAIA?
GAIA is an Unity Asset developed by Adam Goodrich. It aims to help developers to create amazing looking terrains by allowing you to go fully procedural or fully manual or somewhere in between.
Let me explain. GAIA has a lot of useful tools. You decide how many tools you want to use. You can use only some tools, and go manual on some parts, or you can fully go procedural! Yea… GAIA has procedural terrain generation and the results can be pretty unique.
…read more below…
So how are Unity’s normal terrain tools?
Well, you right click in the Hierarchy, 3D Object > Terrain. This will create something that looks like a basic plane. But if we check the Hierarchy we can see that we have a new Terrain component.
On that component you can rise/lower the terrain, paint textures, paint trees and other small foliage all using some brushes. You can quickly realize how tedious this is. Not only that but you will manually have to add all your textures, trees, foliage, etc.
In this window you can find all the tools you need. In this first tutorial we will mostly focus on the “Standard Tab”. Everything is pretty intuitive.
First we will “Create Terrain & Show Stamper“. Once we have the terrain that we want, we will “Create the Spawners“. When that is done we will add the final touches by “Creating the player, Wind, Water and Screenshotter“.
Ok I know you might still be a bit confused. What is a stamper? What are spawners?
Let’s just start by creating some procedural terrain.
Using GAIA’s Tools to create a procedural terrain
When we press the “Create Terrain & Show Stamper” GAIA will automatically create for us a couple of Game Objects. First of all it will create an Unity Terrain. A great thing that GAIA does besides creating the terrain, is automatically adding the textures, trees, foliage to the terrain component. This will greatly help us speed up the process later when we want to use some of those tools manually since we don’t have to add those resources ourselves. In case you are wondering how GAIA knew what resources to add, look on the above screenshot at the Gaia Manager window. You have there GaiaResources… you can configure this asset file yourself in case you want it to automatically add different resources than the default ones.
Gaia also created a “Stamper“. We will talk on how to use the Stamper later when we will create our terrain manually. But just so you get the idea on how Gaia is doing the randomization I will explain some stuff. Gaia has a folder called Stamps. There you will find a lot of height maps. Based on the randomization settings (that you will see later), Gaia will pick some of those height maps and “stamp” them into the terrain.
If you select the “Session Manager” game object you will see a Gaia Session Manager script that has this Random Terrain Generator thing. I think this is pretty self explanatory. You can set up the number of stamps you want Gaia to apply, the width, height scale. The Border Style is basically want you want the terrain border to be. Water, will just surround your terrain with water creating an island. Mountains will add mountains to your edges and you also have none.
Then you have a long list of “chances”. The higher you set up the changes, the more Gaia will pick a stamp from that folder. If you notice that the above folders from the Stamps folder match the “Chance” from the Random Terrain Generator.
If you want to add more stamps you can create your own height maps or you can purchase some of the height map packs from the Unity Asset store, like Backwoods Desert Area Stamps or Highlands – Terrain Stamps Pack for Gaia Vol 6. The developer Backwoods actually has a lot of stamps!
Once you are happy with your settings, you can hit the Add Stamps button. Gaia will then start to create a random terrain.
This is the terrain that I got. I am pretty happy with it. If you however don’t like what you see you can click the “Reset Session” button and try again.
The next step is to click the “Create Spawners” button from the Gaia Manager window. That button will create five other game objects. Each of those spawners will help us automatically enhance our terrain without us having to do manual work. Those are some of the tools I told you about at the beginning of this article. You chose what tools you want to use. If you want to plant your trees manually, don’t use the clustered & coverage tree spawner. If you want to texture the terrain yourself, don’t use the coverate texture spawner.
The new created spawners are:
Coverage Texture Spawner – This will texture our whole terrain.
Coverage GameObject Spawner – This will add various objects in our scene. The default will add rock piles, small, medium farms, small villages, etc.
Clustered Tree Spawner – This will create clusters where trees will spawn.
Coverage Tree Spawner – This will fill the whole terrain with trees.
Coverage Detail Spawner – This will create grass and flowers.
I will go over the settings of each of those spawners in a later tutorial. For now we will just use the basic settings. So select the Coverage Texture Spawner.
Notice the Spawner Rules. Those are the textures that were also added to our terrain. You should not have more than 4 textures because of performance reasons. Anyway, just press the “Spawn” button. Gaia will start “reading” the terrain, spot where there is a “high slope” spot where is a lower ground, etc. Gaia will then apply the appropriate textures according to the rules. Here is my result:
As you can see here, I have some sand, some grass, and some rock. The sand was applied there because that area is under my “water level”. You can see this in the last screenshot. We also have the rocks on the steep terrain. It might not look like much right now, but imagine how long it would have taken us to do this ourselves by had. You can now start to polish this yourself if you want.
Now let’s look at the Coverage GameObject Spawner. You have the same thing. A couple of rules. When you press the Spawn button Gaia will look at those rules and randomly spawn objects. In my current terrain Gaia coudn’t find some decent spots to spawn farms and other interesting objects like that, so it only spawned some rocks. After all my terrain is pretty rocky and is surrounded by a lot of water. However here are some screenshots with another terrain that I generated. I used this terrain when I did my tutorial on VR Panorama 360 PRO Renderer. You can even see a 360 Video here . Anyway, here are some screenshots:
Ignore the grass, trees & foliage. Focus on the buildings and the rocks. Those are the objects that are added during this step. Yes, everything was added randomly!
Now let’s have a look at Clustered & Coverage Tree Spawner:
If you are not happy with the amount of trees that you got, just hit that spawn button again. What is cool about all this is that Gaia also adds colliders to the trees. Keep in mind that those Trees are spawned in the terrain. They are not GameObjects into the scene. You can not select & move a tree, so the fact that Gaia automatically adds colliders is a fairly big deal. Huge time saver!
The next step in our Terrain Generation is adding grass and foliage. Like the other spawners, we have some rules. Gaia decides what and where to randomize them based on those rules. In this first screenshot you can see how our terrain looks without any grass and foliage.
Soooo pretty. As you can see this makes a HUGE HUGE difference!
Well, you could say that your terrain generation is complete. You can use your terrain as is, or you can start to polish it a bit to make it more to your needs. However, I will show you the last thing Gaia can do for you in this “Standard Setup”. Go to your Gaia Manager window and press the 3rd Button, Create Player, Wind, Water and Screenshotter.
As you might have guessed, Gaia will create a First Person Character for us, it will place the Water, Wind and it will create a Screenshoter so we can take screenshots whenever we press a key.
Now, in order to do this make sure you install Unity’s Default Packages for Characters & Environment. Go to Assets > Import Package and click “Characters” and after that click “Environment”.
Now you can press that 3rd Button.
Gaia will disable your current camera and it will create the Player. Select your Player GameObject and move it wherever you want to start “the game”. Mine got placed in the place of the first screenshot:
This feels amazing. Remember how hard it was to create terrain in unity? Now look at what we accomplished!
This was only a short tutorial on how you can generate terrain randomly in Unity using Gaia. In the next tutorials I will show you how you can use some of the other tools that Gaia has.
Thank you for reading. If you have suggestions on how to improve my tutorials & videos, drop me an email. I would also like to thank Adam for creating this amazing Unity Asset!