# How to Filter Out Steep Slopes in PCG to Prevent Tree Spawning?

**URL:** <https://forums.unrealengine.com/t/how-to-filter-out-steep-slopes-in-pcg-to-prevent-tree-spawning/2139517>\
**Category:** World Creation\
**Tags:** unreal-engine, question\
**Created:** [November 21, 2024, 1:48am UTC](https://forums.unrealengine.com/t/how-to-filter-out-steep-slopes-in-pcg-to-prevent-tree-spawning/2139517 "2024-11-21T01:48:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoRemains](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NoRemains](https://forums.unrealengine.com/u/NoRemains)\
**Post date:** [November 21, 2024, 1:48am UTC](https://forums.unrealengine.com/t/how-to-filter-out-steep-slopes-in-pcg-to-prevent-tree-spawning/2139517/1 "2024-11-21T01:48:05Z")

</div>

Hi everyone,

I’m working on a PCG graph to generate trees on my landscape, but I’m running into an issue where trees are spawning on steep slopes, such as mountainsides, where they shouldn’t logically appear.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/c/9/2c973052c927aac0399abcad8b3f76efebad02f4.jpeg)

I’ve debugged the PCG points and confirmed that the `Steepness` attribute is present but doesn’t seem to change based on the actual terrain slopes.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/2/c/02c04fce20c968c64446689b9a50796747d529a8.png)

My goal is to filter out points on steep slopes entirely so that trees only spawn on flatter terrain. Does anyone have experience with this or know how to properly calculate or filter steepness in PCG? Any advice, tips, or examples on how to remove points based on steepness would be greatly appreciated.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![NoRemains](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NoRemains](https://forums.unrealengine.com/u/NoRemains)\
**Post date:** [November 21, 2024, 2:28am UTC](https://forums.unrealengine.com/t/how-to-filter-out-steep-slopes-in-pcg-to-prevent-tree-spawning/2139517/2 "2024-11-21T02:28:55Z")

</div>

After playing around with the nodes, I found a `normal to density` node and used the `visualize attribute` node to see what that data looked like on the landscape. I was able to use that density data to filter out the trees using the `attribute filter`.

These are the results so far. Not sure this is best practice yet, but it’s working for now.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/a/9/aa9d9fd5b49826ad9fbfe3354379093b3e07438a.jpeg)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/d/e/0de778dcc31a86b6c7eddf5ca1cdf14d3e9f3af7.jpeg)

---

<div class="post-metadata">

**Author:** ![stilgarnat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@stilgarnat](https://forums.unrealengine.com/u/stilgarnat)\
**Post date:** [February 28, 2025, 9:07pm UTC](https://forums.unrealengine.com/t/how-to-filter-out-steep-slopes-in-pcg-to-prevent-tree-spawning/2139517/3 "2025-02-28T21:07:14Z")

</div>

Hey Kenny, I had the same problem and I found that you can use the rotation attribute to achieve that effect, basically the idea is that you want to keep only elements that are in a given range of rotation.  
We don’t care about the yaw for our purpose :

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/a/2/8a24c5450509e7931f65111cf6b993b4e8e40324.png)

So a very basic setup is just to use 4 attribute filters with the maximum and minimum pitch and yaw

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/7/6/f76f85bb0535af3428a18316a46bbaf4790b66a4.png)

For instance if we want anything on a slope above 30 degrees to stop spawning, you can set up the first roll filter like this

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/e/2/ce22101aba711a4d418a7fd04ddcd82bbaf47e2b.png)

The second like this :

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/4/9/249b910d11e81c2907643fc36847e08f191426f1.png)

And do the same for the pitch filters.

Hope this helps !

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/7/a1737c9005a5152f42572b3d956afc4d9cf5f13a.jpeg)
