Did you know you can spawn foliage meshes on landscapes automatically, on specific texture layer and without having to manually paint using the Foliage Tool?
Once I found out I could do this, I never want to paint using the Foliage Tool again.
In this complete tutorial guide you will learn how to set up the Landscape Grass Output node and spawn foliage procedurally on your landscapes.
Let's get started!
I already have a map setup and terrain ready to go. I am using TimeOfDayTemplate available from File > New:
I have Post Process Volume inserted with the following properties changed:
The terrain heightmap was created in Photoshop using Clouds filter with few adjustments. The size of the heightmap is 2017x2017 (2 square km). Here is what the heightmap looks like:
I imported the heightmap into UE4 and reduced the Z Scale to 50, creating the smooth field plains.
I also increased the Directional Light Intensity to 5 to make it brighter.
First you need a landscape material.
Here is the initial Material setup. It is a 2 texture material with Specular, Roughness and Metallic inputs controlled by Constant1Vectors.
If you need detailed explanation how to create this, watch the video above and also see this tutorial UE4: Step-by-Step to Your First Landscape Material (2 Texture Paint Layers).
I am using Started Content textures but you can use any terrain texture you want. Quixel Bridge contains a lot of great landscape textures to use.
I also used Landscape Layer Blend node with 2 layers:
First Layer Details:
Second Layer Details:
I duplicated the Landscape Layer Blend for Normal Map setup:
I am also using Landscape Layer Coords node for controlling texture tiling. This one node is connected into UV input for all terrain textures so they all tile the same.
Constant1Vectors is used for Metallic, Specular and Roughness. The values are:
With the Material created we can now apply it to the landscape.
Select the landscape in perspective viewport or World Outliner and then in Details panel under Landscape Material, assign the Material:
Landscape will turn black and this is normal. To fix this we need to create Landscape Layer Info.
Switch to Landscape Mode (Shift + 3 if using UE4.25 or later; Shift + 2 if using UE4.24 and earlier):
Tthen switch to Paint tab:
Click on the Plus icon for each layer and choose Weight Blended Layer (Normal) for both texture layers:
When the menu pops up for saving the Layer Info, click OK. UE4 will create a folder with the map name and save Layer Info's into this folder. I rarely change this folder location:
Back in the Material Editor, Right-Click in empty space and insert LandscapeGrassOutput node:
First input element will be named Grass by default. But the name can be changed to anything you want. I leave mine as Grass.
Now ask yourself these questions:
We have two texture layers GrassTexture and DirtTexture defined using the Layer Blend node:
To define which texture layer to spawn Static Meshes on using the Grass Output Node, you have to use LandscapeLayerSample:
Parameter name has to be the same name as one of the texture layers in the Layer Blend node. In my case I will start with GrassTexture:
Then connect Layer Sample GrassTexture output into the Grass input:
Nothing will happen because we have to define which Static Meshes to spawn. For this we need to create Landscape Grass Type actor.
In Content Browser, Add New then Foliage and create Landscape Grass Type:
Name it whatever you want. Then back in the Material Editor and with Grass Output Node selected, assign the Landscape Grass Type as Grass Type:
Now we need to assign which Static Meshes to spawn. Back in Content Browser, double click on the Landscape Grass Type to open its properties. Click on the Plus icon to create the first element:
Under Grass Mesh, assign a Static Mesh you want to spawn:
I am using the free SM_FieldGrass_01 from Open-World Kite Demo from UE4 Marketplace. As soon as you assign a Static Mesh to spawn, you will see it on the landscape, on the grass texture layer.If you can't see grass spawning, make sure you have Real-Time enabled (Ctrl + R).
Adjust the following properties:
For spawning grass Static Mesh, here are my properties I defined:
Tip: I found that if you increase the Scale of the spawned grass, you can decrease Grass Density. This way you can spawn less Static Meshes but maintaining good visuals with less performance hit.
I use UE4 Mannequin Mobile as a human reference scale to judge the size of the spawned foliage. This is absolutely a must.
Here is how to get and use UE4 Mannequin Mobile character scale reference:
Let's add more Static Meshes to spawn within the grass. This will break up the grass repetition and introduce some splashes of color.
Within the Landscape Grass Type properties, click on the Plus icon again to add a second element:
Then go through the properties just like we did for the grass mesh and add another Static Mesh to spawn. Except lower the Grass Density to a very low amount.
Here are my properties for the second Landscape Grass Type element:
Here are the results on the landscape:
Using this method you can continue to add additional elements to spawn Static Meshes on the grass texture layer.
If you paint the dirt texture layer on the landscape, the spawned foliage meshes will be removed:
And if you paint the grass texture layer back in, spawned foliage will re-appear.
You can assign a different set of Static Meshes to spawn on the dirt texture layer.
Here is how.
Create a second Landscape Grass Type actor and name it. You will now have two Landscape Grass Types:
Back in the Material Editor, select the Grass Output Node and create a second element by clicking on the Plus icon in Details panel:
Give it a paramter name (I named mine Dirt) and assign the newly created Landscape Grass Type:
Insert another Landscape Layer Sample and name it the same way as the second terrain texture layer from Layer Blend node. In my case it's DirtTexture. Connect Layer Sample DirtTexture output into the second input of Grass Output node:
Save and go back to Content Browser.
Double click on the Dirt Landscape Grass Type to open its settings. Then go through creating the first element and defineing it's properties the same way we did for the grass and flowers Static Meshes.
You will begin to spawn different set of Static Meshes on the dirt texture layer:
For this tutorial I did create a Material Instance and assigned to the landscape. I converted the following parameters to control:
See this tutorial for creating a Material Instance to have more control and versatility for changing how you want your landscape materials to look on the terrain.
The grass Static Mesh doesn't match the terrain texture underneath. There is an easy fix. You need to add brighten/darken controls to the Albedo texture.
Then connect them like so:
Do this for grass and for dirt Albedo:
Then using the Material Instance, enable Brighten/Darken controls and lower the value below 1. I changed mine to about .2
You can now see the terrain texture under the grass blends and matches the Static Mesh much better:
Decrease the Specular value on the landscape Material to about .15 or so. The default value of .5 is too much and creates a noticeable glare:
Lowering the Specular for landscape materials below .5 has helped to make terrain textures look better.
Be aware that Grass Output Node does NOT have mesh collisions. So for gameplay related foliage requiring collision use the Foliage Painting Tool or Procedural Foliage Volumes.
You don't have to stick with grass and flowers. You can assign tree Static Meshes to create full forests.
`
You now know how to procedurally generate foliage on specific texture layers.
You can add more texture layers into the Layer Blend node and add more elements for the Grass Output node to spawn variety of Static Meshes on your landscape.
Learn EVERYTHING you need to know for how to create/sculpt landscapes and create/paint landscape materials entirely in UE4 without any external software with "UE4 Fundamentals Vol.2: Landscape Essentials".
Home Terms of Use/Trademarks/Disclaimers Privacy Policy Donate About Contact
All content on this website is copyrighted ©2008-2024 World of Level Design LLC. All rights reserved.
Duplication and distribution is illegal and strictly prohibited.
World of Level Design LLC is an independent company. World of Level Design website, its tutorials and products are not endorsed, sponsored or approved by any mentioned companies on this website in any way. All content is based on my own personal experimentation, experience and opinion. World of Level Design™ and 11 Day Level Design™ are trademarks of AlexG.
Template powered by w3.css