Procedural Foliage Volume Based Masking
Having the ability to procedurally spawn an entire forest of trees can be a huge time saver, but what if you want to restrict certain trees to only spawn in certain areas?
To accomplish this you could do a number of things like use multiple Procedural Foliage Volumes or use the Foliage tool to place the trees where you want. However, that adds a lot of complexity and upkeep to your project.
Luckily, the Foliage Types have the option to restrict the placement of the Static Mesh that is assigned to them to a certain layer in the Landscape Material by allowing only that Foliage Type to spawn when that layer is exposed while painting.
No matter which method you use, you will always need to select the Procedural Foliage Volume in the level and click on the Resimulate button to update and see your changes.
The image below shows a very simple Landscape Material setup that will allow for three different Foliage Types to be used with three different Textures.
Notice how each input in the Layer Blend is uniquely named.
This is important because this name is how we associate which Landscape terrain layer the Foliage Type should be restricted to.
Once the Landscape Material has been setup, we now need to setup the Foliage Type so that it can be associated with the correct Landscape layer.
In the image below you can see an example of how a Foliage Type needs to be setup to restrict the placement of the assigned Static Mesh to a specific layer in the Landscape Material.
To set this up for yourself, you will need to do the following inside of the Foliage Type:
Expand the Show Advanced arrow icon to expose the Landscape Layers option.
Press the plus sign icon that is to the right of the word elements to add a new entry in the array.
Input the name of the layer in the Landscape Material that you want to restrict this Foliage Type to.
Once you have the Material and Foliage Types setup, make sure to assign the Material to the Landscape terrain and then start to paint the Landscape as usual.
When you are done painting, or if you just want to see what you have so far, select the Procedural Foliage Volume in the level and then press the Resimulate button to update and apply any changes.
When completed, the foliage that was spawned will be confined to the Landscape Texture it is associated with like in the following image.
If we take a closer look at the image above, we can see that everything has been procedurally placed as expected but none of the spawned meshes intermix with one another.
For example, the leaved trees only spawn where the grass Texture is applied to the Landscape.
If you look closely, you will see that the same occurs with the bush and pine trees.