WoLD Archives Search About Contact

World of Level Design

Tutorials to Becoming the Best Level Designer and Game Environment Artist (since 2008)

UE4: Complete Guide to Spawning Foliage on Landscapes Using Grass Node Output

Category: UE4
January 13, 2021

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!

Video Tutorial

The Setup I Am Using

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:

  • Unbound: enabled
  • Exposure Min/Max Brightness to 1

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.

Creating the Material

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.

Click on the image to see larger size (opens in a new tab)

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.

  • T_Ground_Grass_D
  • T_Ground_Grass_N
  • T_Ground_Gravel_D
  • T_Ground_Gravel_N

I also used Landscape Layer Blend node with 2 layers:

First Layer Details:

  • LayerName: GrassTexture
  • BlendType: LB Weight Blend
  • Preview: 1.0

Second Layer Details:

  • LayerName: DirtTexture
  • BlendType: LB Weight Blend
  • Preview: 1.0

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.

  • Mapping Scale: 5

Constant1Vectors is used for Metallic, Specular and Roughness. The values are:

  • Metallic: 0
  • Specular: .5 (default)
  • Roughness: .9

With the Material created we can now apply it to the landscape.

Assigning the Material on 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:

Adding Landscape Grass Output Node

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:

  • Where do you want to spawn Static Meshes?
  • Which texture layer?

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.

Landscape Grass Type

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:

  • Grass Density: amount of Static Meshes spawning
  • Start Cull Distance: where do you want to start culling, only is used if you have PerInstanceFadeAmount node in the Material (I did not used this in the tutorial)
  • End Cull Distance: where the Static Meshes stop spawning beyond this distance (set in Unreal Units)
  • Scale X, Y and Z Min and Max: size variation of Static Meshes
  • Random Rotation: Random rotation (enabled) or same rotation (disabled)
  • Align to Surface: whether Static Meshes align to surface normals of the terrain or they do not (enable it for grass, flowers and rocks but disable it for trees)

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.

Inserting Scale Reference

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:

Adding Additional Grass Elements

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.

Adding Second Landscape Grass Type for Dirt

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:

Creating Material Instance

For this tutorial I did create a Material Instance and assigned to the landscape. I converted the following parameters to control:

  • Roughness for Grass and Dirt
  • Specular
  • Brighten/Darken of Albedo textures

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.

Match Terrain Texture to the Grass

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.

  • Insert a Multiply
  • Insert Constant1Vector (convert it to a Parameter)

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:

Lower the Terrain Specular Value

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.

No Collisions

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.

In Closing

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.

Download "UE4 Landscape Essentials" Course

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".

SUBSCRIBE & GET FREE UE4 PDF GUIDE

Subscribe to receive NEW/UPDATED and FREE "UE4 Beginner's Quick Start Guide" PDF (150+ pages).

Subscribe and Get Free UE4 PDF Guide

Visit this page for more info about the guide...


Follow WoLD




UE4 LANDSCAPE ESSENTIALS


BEGINNER COURSE TO LEARN UE4


LEARN THE PREPRODUCTION PROCESS


ABOUT WoLD & ALEXG

About World of Level Design

My name is Alex Galuzin. I am self-taught level designer, game environment artist and the creator of World of Level Design.com. I've learned everything I know from personal experimentation and decades of being around various online communities of fellow environment artist and level designers. On World of Level Design you will find tutorials to make you become the best level designer and game environment artist.

Read More »


Home Terms of Use/Trademarks/Disclaimers Privacy Policy Donate About Contact

All content on this website is copyrighted ©2008-2021 World of Level Design LLC by Alex Galuzin. 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 Alex Galuzin.

Template powered by w3.css