This article details the terrain loading system available in Gaia Pro.

What is Terrain Loading?


Terrains can be created / managed in 3 different ways in Gaia:


  • A single terrain covering the desired target area
  • Multiple terrains covering the desired target area, while the terrains are aligned in height, texure etc. at the seams so it is not apparent that the world is being assembled from multiple terrains
  • Multiple terrains covering the desired target area that are stored in separate scenes. These scenes can then be loaded in and out around the player as they navigate through the terrain.

Having a single terrain in your scene is the simplest and most convenient way to handle terrains in your scene. However at certain world sizes you start to run into issues with the terrain heightmap / control texture / detail resolution, or you run into performance issues when all of your game world is being loaded in the scene at the same time. When you use multiple terrains you have the advantage that you can use higher terrain resolution values (since multiple terrains are used to cover the same area). With terrain loading from multiple terrain scenes you can additionally unload terrains distant to the player to potentially save some performance during runtime.

Most modern open-world games use one or the other form of terrain loading to manage large game worlds, often as core part of the engine itself. Gaia can help you to build such a large world by using terrain loading both during design time and runtime.


Things to consider before creating a huge world


While Gaia makes it easier to create a large game world, please consider the following before creating a gigantic world with hundreds of terrains:


  • Using terrain loading adds a lot of complexity to your game - your game code will need to be able to handle it if parts of the world (& the objects on it) are being unloaded / loaded as the player moves through the world
  • Increasing the world size exponentially increases the time required for spawning textures & assets on the terrain, up to a point where it will take hours or days to generate your world
  • The individual scenes still need to be loaded in and out by unity, depending on how much content there is on the individual terrain scene the scene loading process can become a performance bottleneck.
  • Depending on your game type, the world will need to be filled with content as well. This can quickly take up so much time that it becomes unrealistic that you will ever finish your game. E.g. if you create a world sized 25 x 25 kilometres - that is 625 square kilometres. A designer can easily spend an entire work day just to design a single square kilometre - adding towns and enemy camps, distributing loot, fine tuning placements, etc.
    So you would look at 625 days alone to fill those square kilometres with life, without any revisions etc. which can be quite a chunk of work for smaller teams.
  • Many AAA games are smaller than you think when measured in square kilometers / square miles.


This serves not to discourage you to create a large world on your own, but to be realistic about what you can achieve in relation to your team size.

How to enable Terrain Loading in Gaia Pro


Activating terrain loading in Gaia Pro is fairly simple: Just set up the amount / size of terrain tiles you want to create during world creation, and activate the following checkboxes for terrain loading:


  • Create Terrain Scenes - Will create the terrains in separate unity scene files
  • Unload Terrain Scenes - Will unload these terrain scenes right after creation (recommended when creating very large worlds)
  • Floating Point Fix - Enables a workaround that helps with issues regarding floating point precision in the Unity Engine.


By activating those checkboxes, your Gaia Tools and the player will automatically be set up for terrain loading. You can then continue to create your terrains as you would with a single terrain. Unity will prompt you to save the scene if you have not already - this is required from the technical side, Gaia can't create additional scenes if your "master scene" has not been saved yet.


Controlling Terrain Loading during Design Time


When creating your scene while terrain loading is active, most Gaia Tools are set up to recognize this automatically. For example the stamper (which is usually the first tool you will use) will load in terrain scenes in its range of operation automatically, same with the spawner. You should notice terrains loading in and out in the scene as you move those tools around. In the advanced options you can change the loading behavior for those tools:


The different load modes for those tools are:

  • Disabled - will not load terrains at all
  • Editor Selected - will load terrains as long as the tool is selected in the Scene Hierarchy / Inspector
  • Editor Always - will keep terrains loaded even when not currently selected
  • Runtime Always - will load terrains during runtime (usually used on game objects like the player rather than tools)


Additionally to the tools, there is also a general loading range and an origin in the Gaia Toolbar on the top of the scene view:


Adjusting the origin allows you to re-center the scene at a certain point in world space - Gaia will shift the loaded terrains so that this coordinate in world space becomes 0,0,0 in the scene view. In other words, entering an origin of x=400 in there will shift all terrains 400 units negative on the X-axis. This mechanism exists to navigate very large world and to counter potential issues with floating point precision while editing your scene.


The Loading Range defines another area for loading terrains in the scene view that is independent of the individual tools. If you are unsure how large this area is, you can activate "Show Range" to show a gizmo in the scene view.


Runtime Loading / Adding your own Loaders


Terrain Loading during runtime is controlled in a similar fashion as for the design time tools. To make an object load in terrains around itself, you can attach the "Gaia Terrain Loader" component to it. Gaia does this automatically for the player object in a scene where terrain loading is used, but you can set up additional Terrain Loader components on any object you like. The component has the following settings:


Load Mode: The load mode applied to this object. The Load Modes are the same as for the regular Gaia Tools:

  • Disabled - will not load terrains at all
  • Editor Selected - will load terrains as long as the tool is selected in the Scene Hierarchy / Inspector
  • Editor Always - will keep terrains loaded even when not currently selected
  • Runtime Always - will load terrains during runtime (usually used on game objects like the player rather than tools)


When used on a runtime object, you usually would want this to be "Runtime Always".

Refresh Rate Settings:  When the Loading Mode is set to Runtime, you can find 4 settings that control the refresh rate for terrain loading checks. In a scene with 100s of terrains it can become costly evaluate each frame whether a terrain needs to be loaded or not. You can therefore control that terrains that are closer to the loader are being checked more frequently for loading as terrains that are further away.


The "Min Refresh MS" refresh rate is used for terrains at or below the min refresh distance.

The "Max Refresh MS" refresh rate is used for terrains at or over the max refresh distance.

Anything between will be interpolated accordingly.


Loading Range Settings: The Loading Range is determined by a bounding box that determines every terrain that is touched by this box will be loaded automatically during runtime. When the checkbox for "Follow Transform" is activated, the center of this box will be the transform position of the Game Object. If not, you can enter a different point in world space for the center.You can set up the range of the box in the XYZ-dimensions as well. The box is displayed as a black Gizmo in scene view so you can review the range settings accordingly (see screenshot above).


Preventing the Player from falling through the Terrain


A common problem with terrain loading is that the player character / camera might fall through the terrains at scene start since the terrain takes a few milliseconds to load in the scene, which is enough for the player character falling below the terrain collider. You can prevent this with custom scripting, but there is also a small helper script included with Gaia that helps with this problem: You can attach the component "Rigidbody Wait For Terrain Load" to the game object with the rigidbody that is affected by gravity.


This component will turn off the gravity on the rigidbody at scene start, and only activate it after the "Activate Delay" when the terrain below the character has been loaded in. Additionally you can set up one or more components that should be activated together with the gravity. This is entirely optional and can be used e.g. to activate player controls together with the gravity on the player.

Terrain Loader Manager


When you have many tools or many different runtime loaders in the scene, it can become difficult to determine why a certain terrain is currently being loaded (or not). Under "Gaia Runtime" in the scene hierarchy you can find a "Terrain Loading" Game Object that displays the Terrain Loader Manager:


Terrain Loaders Panel

In the "Terrain Loaders" panel you can find a list of all objects with a terrain loading component. The dropdown tells you in which mode these loaders are currently operating in.


You can use this list to analyze which objects are responsible for loading scenes and change the loading mode here directly to stop unwanted loading of terrains. You can create your own loader object by adding the Gaia Terrain Loader component to any game object. (see "Runtime Loading / Adding your own Loaders" above).


Terrains Panel

In the "Terrains" panel you have 3 buttons on the top:

Add Scenes to Build Settings: This will add the scenes associated with the terrains to the project build settings. This is normally done when Gaia creates the scenes initially, but if the build settings / scene setup has changed it might be required to perform this again.

Load All: Loads in all terrain scenes at once. Warning: With a fully populated large world with 100s of terrains this can severly reduce the editor performance, or lead to crashing.


Unload All: Unloads all terrain scenes at once. If there are still loader objects active in the scene, there might be terrains loaded back in by those loaders immediately after.

Below the buttons you can find a list of all available terrain scenes. You can choose to load / unload those scenes manually with the respective buttons. When a terrain scene is loaded in, you can see the references to this terrain scene. A "Reference" means that an object is requesting this terrain to be loaded. As long as the terrain scene has at least one reference remaining, it will stay loaded in the scene. The references created by the Gaia Panel on top of the scene view will shop up as "Terrain Loading" in this view.
You can choose to either select the referencing object, or to remove the reference. When you remove a reference but the corresponding loader is still active, the reference might get recreated immediately afterwards again.


You can use the information displayed in both the Terrain Loaders and Terrains Panel to analyze why a certain terrain is being loaded right now and quickly adjust the loaders in your scene to best suit your current task at hand when editing the scene.