[UE5] PCG Basics: Auto-Placing Forests and Paths by Rules

Created: 2026-07-23

An intro to PCG (Procedural Content Generation), scattering the decoration of a wide outdoor map by rules instead of by hand. Covers the division with the Foliage tool, the steps to grow trees with PCG Volume and Surface Sampler / Static Mesh Spawner, excluding cliffs with a slope filter, and Difference to remove trees only along a spline. We grow a forest on a hill with a graph that keeps trees off the path.

You made a hill with Landscape and hand-scattered trees with the Foliage tool. But when you try to fill a wide map, placing thousands of trees one by one isn't realistic. And even if you think "there were too many trees after all", the work of deleting and re-scattering is another chore.

Solving this "mass placement" by rules instead of by hand is PCG (Procedural Content Generation) . Write "where, what, and under what condition to scatter" into a graph, and placement is generated automatically, re-scattering instantly when you change the conditions. This article covers, from PCG's basics to growing a forest on a hill and removing trees only along a path, while actually growing a graph.

PCG appeared in UE5.2 as an Experimental feature and became Production-Ready in the UE5.7 generation. Either way you need to enable the plugin. Node names can change between versions, so check against the UE you're using.

An auto-placed forest over a hill and a spline path with no trees, with a soft blue clay figure

What You'll Learn

  • What PCG is: write "where, what, by condition" into a graph for auto-placement
  • The division with the Foliage tool (scatter by hand / by rule)
  • Growing trees with PCG Volume and Surface Sampler / Static Mesh Spawner
  • Excluding cliffs with a slope filter
  • Removing trees only along a spline (Difference)
  • Hands-on: a graph with a forest on a hill and no trees on the path

Sponsored

What PCG Is

PCG (Procedural Content Generation) is a mechanism that decides placement by rules (a graph) . Rather than placing one by one by hand, connect "where, what, and under what condition" with nodes, and placement is auto-generated exactly as written.

A figure showing that writing "where (on a surface), what (trees), by condition (exclude steep slopes)" into a graph auto-updates the placement

What's good about PCG? That redoing is free .

  • Want to change the density → just change a number in the graph and everything re-scatters
  • Don't want to grow on cliffs → just add one condition node
  • Changed the shape of the path → the placement follows automatically

Hand-scattered Foliage and Actors needed re-placement with every change. Because PCG holds "rules" rather than "results", change the rules and the results auto-update . This is the key to making a wide map work solo.

The Division with the Foliage Tool

UE has long had the Foliage tool as a means to scatter trees and grass. Since its role differs from PCG, get the division down.

A figure contrasting the Foliage tool scattering a small amount by hand with intent, and PCG scattering a large amount by rules and conditions
  • Foliage tool (scatter by hand): place a small amount at aimed spots with a brush. It suits intended placement like "one marker tree beside the entrance" or "a few rocks at a highlight"
  • PCG (scatter by rule): scatter a large amount over a wide area by graph conditions. It suits condition-driven mass placement like "forest over a hill" or "reeds packed along a riverbank"

The rule of thumb is Foliage for a small, intended placement, PCG for a large, condition-driven placement . Combining both, scattering the broad strokes with PCG and touching up only the highlights with Foliage, is also common.

Your First PCG: Growing Trees

First, let's auto-grow trees on a hill. PCG's minimal setup is a PCG Volume and a PCG graph inside it.

A figure showing the flow where placing a PCG Volume and connecting Surface Sampler into Static Mesh Spawner in the PCG graph grows trees on a surface

The steps go like this.

  1. Place a PCG Volume: place a PCG Volume in the level, covering the range you want trees (the hill)
  2. Make a PCG graph: make a PCG graph assigned to the Volume, and connect nodes inside it
  3. Surface Sampler: the node that "scatters points on a surface". Scatter points targeting the terrain (Landscape)
  4. Static Mesh Spawner: place tree Static Meshes at each scattered point
PCG graph (minimal setup)
Surface Sampler (scatter points on the Landscape surface)
  → Static Mesh Spawner (place tree meshes at each point)

Surface Sampler decides "where to scatter (points)", and Static Mesh Spawner decides "what to place (meshes)". These two line trees up on the hill. When no trees come out, first suspect whether the Surface Sampler's target points to the Landscape .

Excluding Cliffs with a Slope Filter

Scatter over the whole hill and trees grow even on sheer cliffs, which looks unnatural. So, narrow down where to scatter by condition .

A figure showing that a slope filter excludes the points on steep slopes (where the normal lies flat) among the scattered points, keeping trees only in flat places

Each point scattered by the Surface Sampler holds information about the slope (normal) of its location. Using this, add one filter that discards points on steep slopes .

  • Look at each point's slope and exclude points steeper than a threshold (cliff-like)
  • Place trees with Static Mesh Spawner only on the remaining flat points

Now trees don't grow on cliffs, and a forest forms only on gentle slopes and flat ground. Placement gets smarter just by adding one condition node , that's PCG's strength. Scatterings like grass only on steep slopes and trees on flat ground can also be made with combinations of filters.

Sponsored

Removing Trees Only on the Path with a Spline

When you want to run a path through the forest, you can't walk if trees grow on it. With PCG, you can exclude placement along a spline (the path's line) .

A figure showing cutting a band around the path drawn with a spline using a Difference node, so no trees grow on the path

What you use is Difference . This is the node that "subtracts range B from range A".

  • A: the range to scatter forest (the whole hill)
  • B: around the path drawn with the spline (a band range)
  • A − B: scatter trees only in the range excluding the path band

Do this and no trees grow on and around the path drawn with the spline, and a clean path runs through. And re-bend the spline, and the tree-free band follows that shape too . You're freed from the manual work of deleting trees each time you re-run a path.

Sponsored

Hands-On: Growing the Forest-and-Path Graph

An open-field RPG's road, a survival exploration map, a walking sim's forest. "A forest on a hill with a path running through it" is a staple scene of an outdoor map. Here we build one, reusing the hill made with Landscape, growing a graph in three stages.

We're building a forest that scatters trees over the whole hill, excludes cliffs with a slope filter, and removes trees in a band along the spline path .

Here's what it looks like running. A forest spreads over the hill, no trees on the cliffs, and a tree-free band runs along the path. And re-bend the spline, and the band along the path instantly follows and changes shape . The work of deleting trees that hand-scattered Foliage would need, PCG finishes just by moving the line.

A hands-on figure showing a forest over the whole hill, cliffs excluded, a tree-free band running along the spline path, and the band following when the spline is bent

The Graph's Three Stages

Add three nodes in order to grow the graph.

The completed PCG graph connecting Surface Sampler into slope filter into Difference (spline) into Static Mesh Spawner
PCG graph (forest and path)
1. Surface Sampler (scatter points on the hill's surface)
  → 2. slope filter (exclude points on steep slopes)
  → 3. Difference (subtract the spline path's band)
  → Static Mesh Spawner (place trees on the remaining points)
StageNodeRole
1. ScatterSurface SamplerScatter points over the whole hill
2. Exclude cliffsslope filterDiscard points on steep slopes
3. Cut the pathDifference (spline)Subtract the path band to remove trees

Verifying It

Regenerate the PCG and you get a forest spread over the hill, no trees on the cliffs, and a tree-free band along the path . Then try bending the path's spline. If the band follows the shape, it worked.

Here's how to narrow it down when it doesn't work.

  • No trees come out at allwhether the Surface Sampler's target points to the Landscape . Check that the PCG Volume overlaps the Landscape
  • Trees grow on cliffs too → the slope filter's threshold. Lower the threshold to exclude even gentler slopes
  • Trees remain on the path / the band is off → check the band width of the spline passed to Difference, or the spline reference

Two things to take away.

  • Redoing is free: this is the decisive difference from Foliage. Density, cliff exclusion, path shape, change the graph and everything re-scatters. No work of deleting by hand
  • Add conditions to get smarter: the more you stack conditions like slope filter and Difference, the more natural the placement. Scatter first, then exclude, growing the graph in stages. If the load of mass placement worries you, lighten it with combinations of Nanite meshes or LOD and culling

Bonus: Good to Know for Later

Add variation to size and rotation. If all trees are the same size and same orientation, it looks obviously "copied". Randomly varying the size and rotation of each scattered point with Transform Points-type nodes makes a natural forest. Along with density (point count, Density), this "variation" is the deciding factor for realism.

Regeneration is basically baked in the editor. The PCG in this article generates (bakes) placement in the editor for use. There's also a use of generating in real time during gameplay, but the load and design get much harder at once, so keeping to the use of baking and fixing in the editor first is the recommendation.

Mass placement is light thanks to instancing. The trees Static Mesh Spawner places are instanced internally (drawing the same mesh together), so even thousands run relatively lightly. Still, overdo it and it gets heavy, so decide the density while measuring with stat unit and the like. What "drawing them together" actually means is covered in Cutting Draw Calls with Instanced Static Meshes.

Summary

PCG, scattering by rules, is grown with this flow.

StageWhat to doNode
ScatterScatter points on a surfaceSurface Sampler
PlacePlace meshes on pointsStatic Mesh Spawner
NarrowExclude cliffsslope filter
CutRemove the pathDifference (spline)

And the principle running through it is to hold rules, not results . Because changing the rules auto-updates the results, you can make the decoration of a wide map work even solo.

With this, you can build the look of an open field without relying on manual work. In your map, where does the path the player most wants to walk run through? First, scatter trees on a hill and run a single path through them.

Further Learning