Masking is an important core concept of Gaia that is found in multiple Gaia tools. An "unmasked" operation like stamping or spawning will affect the entirety of the target area, while masking allows you to restrict the operation precisely to where you want it.
A lot of the inherent meaning of your terrain is created by masking - a sloped area becomes a rock wall as soon as you decide to set up a mask that restricts the rock texture to appear only at slopes of that angle. An intersection of the water plane with the terrain becomes a beach when you decide to spawn sand textures, driftwood and seashells up to 5 meters above the sea level.
This article explains how masks work in Gaia, and also describes the different available mask types.
1. Mask Core Concepts
Gaia Tools that use masks have in common that they perform certain operations with or on the terrain. Some examples for these tools and operations are:
As mentioned initially, an unmasked operation will affect the entirety of the operation area with full strength. This is visible before performing the operation in the preview of the tool usually.
This spawner below for example has been aligned with the "Fit To Terrain" Button. The visualization for this spawn rule is activated (eye icon button), which will show us the outcome of the spawn according to the current settings. The entire terrain is highlighted in green since there is no mask being applied to this spawn rule:
When spawned, this spawn rule would paint the selected texture across the entire terrain in full strength, overriding every other texture that was in that place before.
Since most of the time we do not want a texture to appear just everywhere across the entire terrain, you can add a mask to define where it should appear. Masks can be added to mask lists on the UI with the small "+" button at the end of the list:
Adding a distance mask for example allows you to control the strength of the operation according to the distance from the center. This has various applications, such as fading out the strength of your spawn towards the borders of the area that you are spawning in. With a circular distance mask applied, the visualization of the spawn rule changes like so:
The distance mask comes with a Distance Mask Curve, that controls how the strength of the operation should be applied from the center to the borders. Since the curve is set up to "fall down" from the center, this spawn rule will be weaker and weaker the further away it is from the center of the operation. Here is the curve used in that mask above as a reference:
When we spawn this rule now, the texture is applied just as seen in the visualization:
Please Note: While many examples in this article use spawn rules to demonstrate the functionality of the masks, the same principles apply across the entirety of Gaia whenever masks are used. For example, here is an "empty" stamper set up with a raise height operation, and a Distance Mask being applied:
Just as the texture spawner, the stamper operation is masked down towards the border, creating this smooth hill-like structure. A little secret: The "Stamp Images" that you usually would select for the stamper are technically no different from applying a mask. The core operation of the stamper is "masked down" by the stamp image to take on the shape of the mountains of valleys contained in the image, thus creating the shape that you can apply with the stamper.
2. Common Mask Controls
There are controls that you will find on every mask in Gaia and that always fulfill the same function across all tools and mask types. These controls are:
3. Combining Masks
While applying a single mask is often a good start to influence the operation to execute how / where you want it, it is often not enough to get more sophisticated results. Here for example we set up a stone texture to appear on sloped areas of the terrain, to create the impression of mountains.
This seems to work, but if you look closely you can see that some smaller areas, including underwater show the stone texture as well, since the terrain is sloped there. What if you wanted to additionally restrict the spawning to the higher parts of the terrain only? The answer is to add another mask to the list. An extra height mask can restrict the operation by the terrain height and additionally mask out the lower, unwanted parts of the terrain.
Every additional mask in a mask stack has a "Blend Mode" field. The Blend Mode controls how this additional mask will be combined with the previous masks in the list. The default blend mode is "Multiply" which translates to "the effect of this mask will be multiplied with the results of the previous masks in the list", or in layman's terms: "The new mask will be applied on top of what is already masked down".
Multiply can be enough for most cases, but to get extra control over your mask stack it is good to know the behavior of the different Mask Blend Modes.
4. Mask Blend Modes
Every additional Mask that you add to a Mask List after the first displays a "Blend Mode" field. Here is an overview over the different mask types with a simple example each. For the example, an image mask containing a circle and a cross is being used. Both masks use areas of 50% and 25% strength to better demonstrate the difference between the blend modes.
The circle is first in the mask list, while the cross is being added afterwards under the particular Blend Mode that is being discussed. Take special note how the areas with weaker strength are blended together under the different modes.
This is the default blend mode when adding the 2nd mask to the list. Multiply takes the strength value of the operation, and multiplies it with the new mask entry. The result is that the new mask further "masks down" the operation.
4.2 Greater Than
The new mask entry is applied to the result of the mask list, but only areas where the output of the new mask "is greater than" what the current result of the mask list is, are changing the mask.
Note how in the example image above only the four end points of the cross are being added to the circle mask - those are the only areas where the output of the "cross mask" is greater than the output of the previous circle mask.
4.3 Smaller Than
The new mask entry is applied to the result of the mask list, but only areas where the output of the new mask "is smaller than" what the current result of the mask list is, are changing the mask.
Note how in the example image above the original circle is being carved into - these are exactly the areas, where the cross mask is smaller than the output of the previous circle mask.
The output of the new mask entry is added to the result of the mask list.
Note how in the example image above the intersecting areas of weaker strength from the two masks are being added together, creating a stronger result in that spot than the single masks would have.
The output of the new mask entry is subtracted from the result of the mask list.
Note how in the example image above the cross mask is subtracted from the circle mask, completely eradicating the circle where the cross has full strength and then getting successively weaker, leaving this interesting pattern.
4.6 Which Blend Mode Should I choose?
This is ultimately depends on what you are trying to achieve - none of these modes is "better" than the other, but it rather gives you control how different masks will blend with each other. Most of the times "Multiply" will suffice, because you usually will use additional masks to further refine your operation. However it is good to keep in your mind that the other modes exist if you can't get quite the result you wanted with Multiply alone.
6. Connected Mask Lists
One aspect of masking that might not be visible immediately from the user interface is that there can be different mask lists that can influence each other. Namely there is a "General" mask list in spawners that influences masks inside spawn rules, but there is also a mask list in the Biome Controller that influences spawners.
6.1 The "General" Mask List in Spawners
For example if you look at the spawner, you will notice that the spawner has one "general" mask list on the top of the tool, while each individual spawn rule also has its own mask list:
The difference between the two lists is that the general mask list on top is also applied to ALL of the rules in this spawner. This means you can put general masks that would be relevant to all the rules in the general list on top of the spawner instead of repeating them inside each rule.
For example, imagine a tree spawner that spawns 10 different trees with 10 spawn rules: If you wanted to avoid those trees to spawn underwater, you could set up one general height mask in the general list for this spawner which then would be valid for all the rules, instead of setting up 10 individual ones in each rule.
Whenever you find that a certain mask could be applied to all spawn rules just the same, it is a good idea to place this mask in the general list of the spawner rather than the individual mask list of the spawn rule.
6.2 Masks in Biome Controllers and Spawners
With a biome controller you can spawn multiple spawners together as a biome, and it has also a mask list. This mask list can be used to make the biome appear only in certain parts of your world.
The relationship between the mask list in biome controllers and the individual spawners is similar like the general mask list in the spawner and the individual spawn rules. This means that masks that are set up in a biome controller are passed down into the spawners and will additionally be considered when the spawning:
As an example, this very simple biome controller only uses one spawner and a simple distance mask with a circle pattern which is shown here in the visualization:
If we select the single sample spawner that is part of that biome, it shows the same visualization output as the biome, even though the spawner itself has neither masks in the general mask list or in the spawn rule that we are visualizing.
This is because the spawner inherits the mask list from the biome controller which is then further passed down together with the general mask list into the individual spawn rules.
This allows you to create relatively complex setups for spawning: You could for example set up a biome to only spawn in the lower left corner of the terrain (Biome Controller Mask List). Inside the Biome there is a tree spawner that spawns trees above the water (General Mask List in the spawner) and the individual trees spawn in different noise patterns (Mask Lists in each Spawn Rule). Another spawner in the biome could then spawn corals under the water surface, but both spawners would not exceed the area of the biome since both would inherit the restricting mask from the biome controller.
Please Note: You do not have to use of the full complexity presented here - spawners can operate without a biome, and you can also choose to ignore the general mask list. So you can also create very simple setups where you just set up masks for each spawn rule as you see fit.
7. Local vs. World Mask Space (Gaia (Pro) 2021)
For most mask types the position and the size of the tool that uses the mask does not influence the masking result, other than the operation being applied to a different area. For example a height mask will apply the same logic to the lower left corner of a terrain as it would on the upper right corner, just the selected area is different:
For this mask type, the data of what is selected on the terrain and what is not comes out of the terrain itself, and the position of the tool is not relevant other than choosing where to operate. However there are two mask types where the position can be relevant: Image Masks and Distance Masks.
Both of these Mask Types select an area that is defined by either an image, or an animation curve. For both of these masks, this area will then be applied by default in local space of the tool - meaning the image / distance mask will follow the tool around while it is being moved:
While this can be desirable for some applications, e.g. if you want to repeatedly spawn a certain pattern at a certain location in your scene, it can often be an hindrance. Especially when you want to use an image mask to mark a certain spot of a larger game world it becomes a problem when this mask (that should be tied "in place" on the terrain travels with your tool.
Prior Gaia 2021 / Version 3.0.0 you had to utilize special workarounds with the world designer to make those masks stay in place, in Gaia 2021 you can now change the "Mask Space" setting to make these masks operate in world space directly:
Any image / distance mask that is set up in World Space will not move with the tool anymore. The mask will be tied in place, here is the same spawner from above with the image mask being set up in world space:
Note how the image is tied to the terrain now rather than to move around with the spawner.
Please Note: By default an image / distance mask in world space will be set up to be positioned around X=0 Z=0 and will scale to one terrain, but you can change positioning and scaling to your liking with the additional controls of the mask:
8. The Different Mask Types
This section goes over the different available mask types in Gaia and explains the mask specific settings.
8.1 Collision Mask
The Collision Mask can be used to avoid collisions with game objects and trees on the terrain. By inverting the mask you can do the opposite and force proximity to a tree or game object, e.g. for spawning mushrooms close to a rock only. This animation shows the visualization of a collision mask that has been set up to avoid spawns near the Game Objects:
Please Note: Trees ARE Game Objects of course, but for the context of the collision mask a "tree" means "a game object that was spawned on the terrain as a terrain tree within the unity terrain tree system". If you spawned your trees as game objects instead, you would need to treat them as such for the collision mask settings as well.
A collision mask can have multiple entries to combine the collisions of different objects / trees at the same time. The settings per entry are:
Typical Use Cases: Avoiding trees or game objects while spawning, Spawning objects close to another object, Adjust texturing around objects, Slightly raise or lower the terrain around certain objects with the stamper.
Pro Tip: You can set up two collision masks for the same object with slightly different radii. In this way you can e.g. set up a mask that spawns object close to a rock, but not inside the rock either.
8.2 Distance Mask
The Distance mask allows you to control the operation strength starting from a center point or along an axis. There are settings that can influence the shape / transition as well. This mask can be used for various purposes, but mostly it is used to "fade out" an operation towards the edges. The "hard edges" of this stamp for example were masked down by applying a distance mask:
Typical Use Cases: Fading out an operation along the edges, Creating patterns for spawning
8.3 Global Spawner Mask Stack
This is a highly specialized mask that allows you to "break out" of the restriction of the global / general mask stack of the spawner. The Section "The "General" Mask List in Spawners" explained how the mask list on top of the spawner is being applied to every spawn rule within the spawner. Normally you are then restricted to work within this area / mask as dictated by the general mask list, but by using this mask the general mask list is handled like an entry in the mask list of the spawner instead. This means you can indirectly alter the limitations of the general mask stack for a single rule if you wish to do so.
A simple example: This spawner contains a circular distance mask in the general mask stack. The spawn rule contains an image mask with the Gaia Logo. The Logo is restricted to the area within the circle due to the general mask.
Even if we wanted to, we could not affect anything outside that circle from within the spawn rule. If the Global Spawner Mask Stack is added however, it is possible to draw the logo as an extension of the circle. (The image mask has been set to Blend Mode = Add)
This mask does not have any special settings to configure, it acts more like a flag, if it is being added, then it is active.
Typical Use Cases: When the General Mask Stack of the Spawner is too restrictive for a certain spawn rule.
8.4 Grow And Shrink
Adds or Removes a bit of extra padding to the mask. This can especially be useful if your mask is a combination of multiple masks, and you want to make the affected area a bit smaller or bigger. This mask has no effect on its own, it needs to have other masks in the list before it to have any effect at all.
This animation shows a spawner with the Gaia Logo in an image mask, and a Grow And Shrink Mask is used to remove from / add to the shape of the logo:
The Grow and Shrink mask only has a "Distance" setting which controls the distance of the extra padding / removal.
Typical Use Cases: Making the output of a mask a little bit larger or smaller.
8.5 Height Mask
One of the most important masks for spawning, this mask allows you to select areas according to the terrain height. This allows you to spawn vegetation etc. according to terrain height, but also to avoid spawns under the sea level. You can also use transitions to e.g. make grass fade out towards the top of a mountain.
Here only the higher parts of the terrain are being selected with a height mask:
Typical Use Cases: Avoiding spawning under water, spawning by height in general.
8.6 Image Mask
Uses an image / texture as basis for the mask. This mask type is also the foundation for the stamp shapes in the stamper. There are many different things you can do with an image mask: Spawn field or path textures, define where a certain biome appears in your world, spawn based on a hand drawn image that you scanned in, etc.
Here is an example of an image mask using an "X" graphic as mask (as seen in the blend mode examples in this article as well). The texture used is the black and white image in the lower right corner.
Typical Use Cases: Stamping, Restricting Spawning / Biomes to arbitary areas, spawning in special patterns
8.7 Noise Mask
Noise Masks bring randomness into your operations, which can be useful in many scenarios. Spawn patterns derived from randomness appear natural, and noise can also hide artificial borders, e.g. when spawning trees based on height it can be good to also use noise in this process to hide the fact that the trees only appear at a certain height level.
In this example, the trees on this terrain were spawned with a simple height and noise mask combination to achieve a somewhat interesting distribution with denser areas and clearings (animation alternates between visualization / spawn result):
Please Note: The noise mask might seem intimidating since it has a lot of settings, but you do not need to understand all of them to get good results with a noise mask. Usually it is enough to select a noise type and adjust the scale and position of the noise a bit.
Typical Use Cases: Creating Natural Spawn Distributions, Hiding artifical looking borders, Mixing two asset types, Stamp Generation, Adding Randomness
8.8 Slope Mask
This is another very important mask for spawning - the slope mask allows you to avoid or seek steep areas on the terrain to spawn the appropriate assets there. In this way you can spawn houses and trees on even terrain, and rocks or cliffs on rough terrain only.
This example selects all areas with an incline of 15 degrees or more, basically selecting "the walls" of the terrain:
Please Note: Height and Slope mask are very similar in their way of modeling a transition between a minimum and maximum value.
Typical Use Cases: Avoiding / seeking steep terrain in spawning.
8.9 Smooth Mask
This mask will smooth the current mask output at this point. This can be used to get a softer transition into the masked area.
For this example a smooth mask is used to smooth up the Gaia Logo in an image mask:
The smooth mask only has two settings: Verticality, which controls whether the smooth effect should be applied rather inwards or outwards, and the blur radius which controls the strength of the smoothing.
Please Note: It is possible to perform multiple smooth passes by adding multiple smooth masks if the maximum blur radius should not be enough for your purpose.
Typical Use Cases: Softening up hard transitions in masks, removing artifacts, blending in masks better with the existing terrain.
8.10 Strength Transform
This is a legacy mask from back when there was not a strength transform built in in any mask already anyways. Please see "Common Mask Controls" in this article for more information. You can still use this mask type, but there is no advantage over using the built-in strength transform curves.
8.11 Terrain Texture
Allows you to use the distribution of one of the terrain textures as a mask. This can be useful if you want to spawn a certain asset type on a certain texture only, e.g. a grass terrain detail on a grass texture.
This example shows how a terrain texture mask selects only the green grass textured areas on the terrain:
The Texture Mask only got a single setting that lets you select a texture which is taken as basis for the mask. However there is one pitfall with this setting: The setting links to a Texture Spawn Rule in a Gaia Spawner, not directly on a Terrain Texture on the terrain!
Here is an example: The available texture spawn rules from the texture spawner (left) are what drives the dropdown selection of available textures in the mask in another spawner (right)
This might seem complicated at first, if all you want to do is to select a terrain texture for a mask, however linking to a terrain texture directly can lead to various technical issues, especially if the mask is about to be saved as part as a more complex spawning setup in a biome. If that biome is transferred to a different terrain, it is not guaranteed that the texture will be on the same index on the terrain, or the exact same terrain layer asset is used.
In short: by linking to a texture spawn rule instead to the terrain directly, it is warranted that this mask is transferable to other terrains / scenes regardless of the texturing state of the target terrain.
If you do not intend to spawn textures with Gaia, and you therefore do not have any texture spawn rules to link to, you can create a dummy spawner that just holds the texture spawn rules to link to, but that you never execute on the terrain. If the terrain is already textured this can be done very quick by
1. Creating a new empty game object
2. Attaching a Gaia Spawner component to it
3. Using the "Import Terrain Resources" feature under Advanced > Resource Management in the Spawner.
This will import each texture on the terrain as a spawn rule, and your dummy spawner will be all set up so you can work with those spawn rules in a texture mask now.
Typical Use Cases: Spawning on a texture or avoiding it for spawns, applying stamper effects to a certain texture only
8.12 World Biome Mask
The World Biome Masks are a construct to support world scale masks in Gaia versions prior to Gaia 2021 / Version 3.0.0. Those are generally not required anymore in Gaia 2021. For more information on how to use these masks and how to replace them with the newer versions in Gaia 2021, please visit the following articles:
Creating a World Biome Mask for Gaia 2 / Pro
Migrating World Biome Masks to World Space Masks
8.13 PRO Concave Convex
This mask is available in Gaia Pro only.
The concave / convex mask allows you to select concave and convex surfaces on the terrain - in other words you can select the smaller nooks and crannies on the terrain which might be difficult to capture otherwise.
This example shows a selection of concave (red) and convex (blue) features on a terrain:
The Concave Convex Mask has two inputs: "Concavity" which controls whether this mask will select rather concave or convex areas, and "Feature Size" which controls the size of the features to be captured. (Smaller = the mask will rather go for the smaller details on the terrain)
Please Note: Due to the technical nature of an algorithm that detects concave / convex areas, this mask will become weaker towards the borders of the operation (since there is less surrounding terrain information to check for convexity / concavity anymore). This can lead to the Convex / Concave mask creating grid patterns when it is spawned in iterations across a larger world, please see here for more information:
Gaia Pro is spawning Grid Lines.
Typical Use Cases: Spawning a contrasting texture in smaller ravines on the terrain to bring out details, snow accumulation in convex areas.
8.14 PRO Hydraulic Erosion
This Mask is available in Gaia Pro only.
The Hydraulic Erosion Mask simulates an Erosion operation on the terrain and provides information about this process in 3 separate categories that can be used as a mask.
On this terrain, the information about the water flow is selected in an Hydraulic Erosion Mask:
The Hydraulic Erosion Mask lets you select between 3 different Output Results which are different data layers from the Erosion Simulation on the terrain:
* Sediment (Areas where sediment would be deposited during the process)
* Water Velocity (Areas where water will flow rapidly during the process)
* Water Flux (The preferred path of the water while running down the terrain)
The remaining input fields control the simulation of Erosion on the terrain that was used to produce the output layers:
There are no comments to display.