The Spawner is one of the most powerful tools in Gaia: It places resources such as Textures, Trees, Terrain Details (Grass) and Game Objects on your terrain with intelligent placement rules. This article describes the spawner in detail.
1. Spawner Basics
One of the most time consuming tasks when creating a terrain can be to determine the positioning of Resources on the terrain. There are a few tools in the Terrain Inspector that allow you to hand-place textures and trees etc., but doing so for an entire terrain can take multiple hours. As soon as you wish to make fundamental changes on the terrain - such as moving a mountain elsewhere for gameplay reasons - you need to spend hours again adjusting placements of textures and other resources again to accommodate for that change.
The Spawner solves this by letting you define Spawn Rules for your Resource placement. A Spawn Rule does contain settings for the resource itself (e.g. which texture to spawn), but also settings for where to place that texture on the terrain. By following the settings defined in the spawn rules the spawner can perform resource placement in a fully automated fashion, from adding the resource prototype to the terrain to the placement of the individual objects. Once a spawner has been set up, it can be run as many times as you like and can also be used again in different scenes / different projects.
To operate the spawner, you would need to perform at least these steps:
- Position the Spawner over the terrain using the transform component or the position Gizmo in the scene view (this step is only relevant when you want to spawn in a limited area on the terrain)
- Set the Spawner Range so that it matches the desired area where you want to spawn. (Again only relevant when spawning in a limited area)
- Make sure you have some spawn rules set up in the spawner
Spawn the resources from the spawn rules by either selecting "Spawn Local" to (To spawn the resource in the designated area you created in Step 1+2) or "Spawn World" (To spawn the resources everywhere, including multiple terrains)
This is a bit oversimplified since there are a lot of settings and features for the individual spawn rules that will all be detailed further down below, but the core principles of operating the spawner are that simple, set where to spawn by positioning the spawner, set what to spawn via the spawn rules, then click one of the two buttons at the bottom.
The following Chapters will go more into detail explaining the individual settings and features of the spawner.
2. Spawn Settings
On top of the spawner you can find general settings for the spawner that will influence all of the spawn rules. These settings are:
General Mask Stack
Below the general settings you can find a section for Mask Settings that will be applied to all spawn rules below. Masks are a way to determine placement of the resources on the terrain. Masking is a complex topic that has its own article in the knowledge base: Using Masks In Gaia
Please note that this is the mask stack of the spawner itself, while each spawn rule can have a mask stack of their own:
The stack in the general spawner settings will be applied to all the rules below, while each rule has a mask stack of their own. If there are both masks in the general mask stack and in the rule mask stack, the masks will give a combined result:
In the example above, there is a height mask in the general settings and a slope mask on the spawn rule for the snow. The end result is that the snow will only appear on high, sloped areas on the terrain (as indicated by the purple visualization).
You need to consider if you want to put a mask into the stack of the individual rule, or in the general mask stack of the spawner itself. E.g. if you set up a height mask to spawn only above 100 meters, none of the spawn rules below will bear any results below 100 meters anymore, which can be good or bad depending on what you want to achieve with the spawner.
From a different perspective, if you find putting yourself the same mask settings in multiple rules, you could consider putting this mask in the general mask stack of the spawner itself.
"Fit To" Buttons
At the bottom of the general Spawner Settings you will find two Buttons: "Fit To Terrain" will adjust the spawner to be aligned with the current terrain it is hovering over, "Fit To World" will align it to all terrains to the scene (as long as the combined size of the terrains does not exceed the maximum range of the spawner)
Note that these buttons and the positioning of the spawner are only relevant when you want to execute the spawn in a restricted area, if you want to spawn across the entire scene, the position / range is being ignored and the spawn will take place on all terrains in the scene anyways.
3. Spawn Rules
The spawn rules are where the "what you want to spawn and where you want to spawn it" is defined. The spawn rules are presented in a list, where each entry is its own un-foldable panel. The controls for the list header are as follows:
The controls for each Spawn Rule Panel are similar, but the functionalities rather refer to the rule itself than the entire list of rules. The controls for each spawn rule panel are as follows:
3.1 Resource Settings
As mentioned before, each Spawn Rule is responsible for spawning a certain resource on the terrain. To determine what type of resource the rule spawns, and what the parameters for this resource are, are set in the Resource Settings foldout within the spawn rule. This foldout can be found right under the name for the spawn rule:
3.1.1 Resource Types
Inside the resource settings, there is a Resource Type selection that decides which kind of resource you want to edit. The Resource Type distinguishes between the various object types that you can place on an unity terrain. Most of these types are not an invention by Gaia, but are rather a specific terrain feature offered by Unity for the terrain object. E.g. when you spawn a tree with Gaia, Gaia will take the tree prefab and add it in such way as if you would have placed the tree manually using the Terrain Tree system. This ensures that other assets that work with Unity terrains work on terrains created with Gaia as well.
The types that you can currently spawn with a Gaia Spawner are:
For each of these resource types, you can start to add individual resource entries in the spawner from the "Selected Resources" dropdown. For example, if you have already maintained two resource entries for two Rock model Game Object Resources, your "Selected Resources" dropdown would look like this:
When you select "Add New GameObject..." it will create another GameObject Resource entry for you that you can edit:
One Resource entry can be re-used by different spawn rules in the spawner - this is useful if you e.g. want to spawn the same texture using two different mask setups.
Depending on the selected type, you can enter all the settings that will control the appearance of your resource on the terrain.
Please Note: The amount of settings for resources might seem overwhelming at first, but the resource will usually spawn fine with just the default settings. So for adding a new tree for example it is enough to enter the tree prefab, and then only tune resource settings as you need them, e.g adjust the spawning size.
After selecting your resource for your spawn rule ("What to Spawn") you can set resource specific spawning settings ("How to Spawn") which will then be executed within the area defined by the Masks of the Spawner and the Spawn Rule ("Where to Spawn")
Since both the settings for the resource and their spawning setting change between the selected resource type, the following section will describe the resource setup and spawning settings for the available resource types.
3.1 Spawning Resources
3.1.1 Terrain Textures
Please Note: The terrain texture settings are mostly identical with the settings that you will find on the Unity Terrain Layer. When a terrain texture resource is spawned on the terrain, a Terrain Layer with those exact settings will be created on the terrain. It is recommended to read the documentation on the Terrain Layer in the unity manual as well, because there is interesting information on how the terrain engine handles certain aspects of these settings.
Please Note: If this texture has already been spawned / added on the terrain, you need to click the "Refresh on Terrain" Button to update the Terrain Layer with the newest values so the changes become visible on the terrain.
Textures do not posses any spawning settings. Since textures are "painted" on the terrain, the texture, as it is set up in the resource settings, will simply appear in the areas selected by the mask settings of the spawn rule and the spawner. Here is an example of the visualization of a grass texture spawn rule, and the final texturing result. The area highlighted in blue becomes the area where the grass texture is placed during the spawning.
Please Note: Spawning the Textures works like painting with colors on a canvas. This means that:
1. Texture spawning order can influence the spawn result: If you spawn a cliff texture on mountain tops and then a grass texture that goes everywhere on the terrain, the cliff texture will not be visible anymore, since it was overridden by the grass texture. You would need to spawn the grass texture first and the cliff texture on top of it instead. You can reorder the spawn rules with the up and down buttons to change the order of execution.
2. You do not need to remove / erase textures from the terrain - to start over with texturing, simply spawn over the existing textures. We often receive support requests from users that ask how they can "erase textures to start again" so they can get the original checkerboard "empty" terrain back.
This is possible to a certain degree by removing the terrain layer prototypes from the terrain, but as soon as you start adding terrain layers to your terrain, unity will display the entire terrain in that texture anyways.
Instead, ask yourself "which texture would be the default texture on my terrain?" Usually that would be a basic ground texture like sand, grass, gravel, etc. Take this texture as your first texture in your spawner, and set it up to not use any masks at all so it will be spawned everywhere on the terrain.
This texture will then act as your "foundation" on the canvas where all other textures are placed upon. This approach also has the advantage that your "foundation" will reset any previous texture spawning so you will always start with a clean slate when spawning.
3.1.2 Terrain Details (Grass)
Please Note: The terrain detail settings are mostly identical with the settings that you will find on the Unity Terrain Detail Prototypes. When a terrain detail resource is spawned on the terrain, a Terrain Detail prototype with those exact settings will be created on the terrain. It is recommended to read the documentation on the Terrain Layer in the unity manual as well, because there is interesting information on how the terrain engine handles certain aspects of these settings.
Terrain Details can be displayed in multiple ways:
- As a texture, that is rendered with a simple Billboard shader
- As a texture, that is rendered using the unity grass shader
- As a mesh, that is rendered using the unity Vertex Lit shader
- As a mesh, that is rendered using the unity Grass shader
You can use these modes for your terrain details that you set up in Gaia as well, by chosing the appropiate combination of settings, (e.g. supplying a mesh and then selecting Render Mode = Vertex Lit if you are going for that combination)
The density of the terrain details is controlled by multiple factors:
- The Terrain Detail resolution setting in the terrain inspector / when creating a terrain from the Gaia Manager: This setting controls how many "terrain detail pixels" or cells are available to place terrain details on the terrain. The more cells are available, the denser the possible placement for terrain details. Cranking this setting up alone will not produce more details, they need to be spawned while using the higher resolution setting as well.
The "Detail Density" setting in the terrain Inspector: Controls how many terrain details Unity will render. It is important to know that even though you might have a lot of terrain details spawned, those might not be visible due to this setting.
The "Global Spawn Density" setting on top of the Spawner. Since this setting controls the overall spawn density of Gaia, it will also reduce the amount of terrain details being spawned if this setting is being lowered.
The "Detail Density" setting in the spawn rule - Controls the density per individual grass resource that you spawn
You do not need to worry about these settings immediately, but you should be aware that these exist when you want to fine tune grass placement or optimize performance.
Terrain Details are not supported in HDRP - The HDR Pipeline does not support the terrain detail system yet. You would need to create your own HDRP grass shader or look for HDRP compatible grass rendering tech on the asset store.
Please Note: If this terrain detail has already been spawned / added on the terrain, you need to click the "Refresh on Terrain" Button to update the Terrain Detail Prototype with the newest values so the changes become visible on the terrain.
Terrain Details have the following settings that influence how the Grass Resource is being spawned:
3.1.3 Terrain Modifier Stamp
The resource settings for the terrain modifier stamp mostly mimic the settings found on top of the Gaia Stamper tool. During spawning this resource, a temporary stamper will be created with the settings that you make here and will be stamped down once in the spawner range. The settings behave like they would on the standalone stamper, so it can be helpful to set up a stamper first, experiment with the settings until you get the result that you want, and then set up the Terrain Modifier Stamp resource.
For an example setup, please see the "Terrain Modifier Stamp Example" spawner that comes with Gaia. You can add it to your scene via the Advanced Tab > Gaia Tools > Add Existing Spawners. This spawner will spawn a couple of trees and rocks on the terrain, the trees will then be lifted up while the rocks will be sunken down in the terrain.
Please Note: Since the terrain modifier stamp alters the terrain height rather than spawning things on the terrain, the preview of a rule with this resource type will display akin to what you would see in the stamper:
Please Note: Since the terrain modifier stamp alters the terrain height, Gaia will take a backup copy of the terrain height the first time a terrain modifier stamp is executed. When the spawner is then executed again, Gaia restores the backup of the heightmap first - otherwise the stamper would be applied to your terrain further and further which could bear undesirable results.
Gaia will warn accordingly before restoring the heightmap, since this would also set back manual edits of the terrain:
Please Note: The mask stack for a Terrain Modifier Stamp rule has an additional setting to regulate the "Stamp Influence" for the masks, just as if those masks would be used in the stamper itself:
3.1.4 Terrain Trees
Please Note: The terrain tree prefab that you provide here will be the one that will be added as a tree prototype when you spawn the tree on the terrain. The prototype will also inherit the bend factor from the resource settings, the other resource settings are unique to Gaia.
Tree prefabs can only use simple colliders (which will be merged into a single collider with the terrain during runtime) and cannot have scripts or other complex components stored on them. This is a limitation of the Unity terrain system and is often an issue when trying to create interactive trees. You need either to employ workarounds to make trees interactive with these restrictions in place, or spawn trees as Game Objects instead.
Tree Resources have an unique "Switch To Stand-In Button" available that lets you quickly exchange the tree model with a striking red stand-in model - this is to identify the tree you are editing on the terrain, but also to determine where instances of this tree have been spawned in a densely populated forest. Here is an example, without the stand-in feature it would have been difficult to identify the exact spawn locations of the spruce tree model inside the forest:
Please Note: If this terrain tree has already been spawned / added on the terrain, you need to click the "Refresh on Terrain" Button to update the Terrain Tree Prototype with the newest values so the changes become visible on the terrain.
Terrain Trees have the following settings that influence how the Tree Resource is being spawned:
3.1.5 Game Objects
Please Note: Unlike the other resources, Game Object resources do not have a prototype representation on the terrain object. This is because Game Objects are just that - they will be created as regular part of your scene and are not directly dependent of the terrain object at all. If you are having any object that does not fit in the Texture / Terrain Detail / Tree categories, you can still spawn it as a Game Object.
Editing a Game Object resource is also special in so far as you can add multiple prefabs for one spawn rule all with individual resource settings each.
This might seem overly complicated first, but makes sense when you spawn more complex objects like houses or other Points
Of Interest - there you can spawn an entire group of Game Objects to build a larger connected structure. For more details on spawning POIs, please see this article.
You can add and remove prefab instances with the respective buttons in the list of prefabs. There is also a drag and drop box in the advanced settings panel that allows you to drag a selection of Game Objects onto the spawner. The prefabs dragged & dropped in this fashion will then be set up in the resource settings with the positioning and scaling kept intact - this is useful for creating more complex Game Object spawn rules consisting of many objects.
Game Objects have the following settings that influence how the Game Object Resource is being spawned:
3.1.6 Spawn Extensions
Please Note: Spawn Extensions utilize the same settings as Game Objects - the difference between the two types is that instead of a Game Object being created in the scene, a function on the spawn extension script is being called. Instead of regular prefabs you maintain Spawn Extension prefabs where the Prefab needs to have a script on them that implements the ISpawnExtension interface.
Other than that, the settings for Spawn Extension function the same way as for Game Objects above - if you are interested how one of the settings works, please look up the section on Game Objects above.
The Probe Resource Type allows you to spawn Light and Reflection Probes in similar fashion like you would spawn a Game Object. Note there is also a way to spawn the Probes from the light baking tab in the Gaia Manager without using a spawner.
Besides the name, the available settings are vastly different between spawning Light and Reflection Probes. Reflection Probes have a couple of options that control the baking behavior, while Light Probes do not require any additional setting at all since the main purpose of the light probe is to collect lighting information at a given position during the light baking process.
The options for the Reflection Probes are:
Please Note: Most of these settings are not Gaia exclusive, but are rather the same settings you would find on a manually placed reflection probe. You can find out more about these probe settings in the Unity manual about Reflection Probes.