Building a 32k Terrain in Unity Using Sectr and Gaia

Building a 32k Terrain in Unity Using Sectr and Gaia

Part 1 – Initial Setup

A couple weeks back (at the time of this writing anyways), folks were posting questions on the Unity3D forums within the Gaia thread questioning how Gaia would work with large terrains.  Some asked about 16k and I think someone asked about 32k.  In general practice, terrains this size are a ridiculous concept in Unity.  You may be able to make them, but once you start adding grass, trees, and other game objects..  Well, lets just say unless you are on some type of massive computer system, you will quickly see the error in your ways!  Usually even with a 2048 x 2048 terrain, the size that the Gaia terrain tool defaults to building, can become pretty bogged down once fully spawned on an average computer system.

At any rate, instead of providing the usual response stating that a terrain that size isn’t even practical in plain Unity, I decided to look at it from a different angle.  What if we built a large terrain, stamped it with Gaia, and then used Sectr Stream to slice up the terrain in more manageable sizes, and THEN started spawning everything with smaller Gaia spawners within the sliced up scenes.  The more I thought about it, the more I wanted to try to do it.  And since so many were asking for it, I decided to do it as a tutorial.  And here we are!  (I posted original part 1 of the tutorial in the Gaia thread on the Unity forums.)

The Test Begins!

At this point I have verified that Gaia Manager is able to create a 32k terrain and stamp it with no issues.  Well, I should say no errors.  The only issue (which really isn’t an issue depending on what you want) is by default, the stamp will stretch across the terrain.  This will end up stretching the detail and get rid of any fine terrain features. BUT, this can be really nice if you are just looking for some overall surface definition where you are going to stamp other features (with Fit to Terrain unchecked) on top of (or into) that initial stamp.  This could be good for something like an ocean floor where you are only going to and detail to certain underwater areas or, in the case of the screenshots below, you want to stamp an island stamp stretched in order to be the outline of a continent where you will be stamping detail on top of it.

So I’ve started capturing a series of screenshots to go through the process.  I’m not finished yet but I wanted to share this part of it to maybe help some of you who are planning to do something like this in the future.  It can also serve as a way to set up a multi-tile area now while waiting for Gaia to add the multi-tile support coming in Gaia 2.0 which Adam is going to start working on at some point after Gaia 1.5 is released.  The screen shots below will get you up to the point where you have your initial continent stamped and are ready to start planning and stamping features onto the continent.  I will work on getting the next section done this week and post next weekend.  That is the goal, anyway!  Enjoy!

Preparing Gaia for the Monstrous Terrain

1-32kGaiaDefaultsThe first thing you want to do is duplicate your GaiaDefaults file in the Gaia -> Data folder.  I renamed my duplicated defaults file to 32kDefaults.  You shouldn’t really need to duplicate the resources file since you wont actually be spawning anything until after the terrains are sliced (future tutorial).  However, in my test I duplicated it anyways and renamed that file 32kResources.  I made sure my sea level matched in both files and changed the Terrain Size in 32kDefaults to 32768 (32k).  I also changed my height to 2000 just in case some of my mountain areas got a bit high in any part of the continent.  I left the other Resolution Settings the same, mainly because I struggle with the concept behind all of them but also because my goal terrain size is actually going to be a 1km square terrain (although it might actually be more practical to go to 512 since we will be streaming and loading several tiles at the same time in the end).

2-32kTerrainCreatedAt this point I have gone into Gaia Manager, dragged my new 32kDefaults file into the defaults field, dragged the 32kResources file into the resources field, and in the Standard tab selected clicked the first button to create terrain and add stamper.  As you can see, the 32k terrain was created with no issues.  So far so good!

Adding Sectr into the Mix


3-CreateGridUsingSectrTerrainNext, I decided to go ahead and get a grid setup so I could see how my terrain would be splitting when I get to the point of cutting it up.  For this, I installed SECTR Complete into my project and then (as show above) I navigated to Window -> SECTR -> Terrain.  This opens the window shown to the right.

4-GridOptionsFor the terrains window, make sure you have the terrain you want to create your grid for chosen in the list.  Most likely it will be the only terrain in the list.  In my case I wanted to divide everything into a 1k grid.  So I set my width and length to 32 and left all the other settings at default.  Actually, I’m not sure if Split Terrain is on or off by default, if it is checked be sure to uncheck it.  We don’t want to do that yet. :)  Once you have changed your settings, press Sectorize Terrain.

5-TerrainGridof1kmSectrsAt this point, you should see a grid similar to the one to the right and your hierarchy is now LOADED with a bunch of SECTR objects!  Each square on the grid in the end will represent a 1km x 1km terrain tile.  One thing I did at this point, as you’ll partially notice in the screenshot, is create an empty game object and rename it SECTR and then two empty game objects as children (one named Terrain and another named Portal).  I then highlight all of the portal objects and in the inspector I uncheck them to disable them.  Depending on how powerful your computer is, this may take a little time and your computer may seem to hang (mine seemed that way), but once the check mark is gone it should run a bit better.  Then I click and hold down mouse button and drag them up to be children of Portal.  I then do the same for the Terrain files (except leave them enabled) and drag them into Terrain.  I then fold (close) both those groups to have a more tide Hierarchy view.

At this point we are ready to stamp.  Unfortunately Unity limited the number of images for the post on the forums and this is where I ended Part 1.  The next part will show how I go about stamping this huge a@#$% terrain. :p

Hope this helps to spark some thoughts on how to handle the huge terrain dilemma. And remember, to follow along with this, I am using SECTR Stream (available in either SECTR Complete or as a separate product) which is not part of Gaia.