How to use sampled texture for anything other than setting the "density" of a point in PCG

We’re using an erosion simulation to generate multiple landscape textures: heightmap, plus soil types to apply landscape materials, and plants maps to grow plants according to what kind of soils and moisture levels they need to grow.

I’ve been trying to use PCG to spawn trees on the map based on the texture, here’s a small example screenshot where the areas for broadleaf trees have been tinted red.

I used “Get texture data” node to get the data from my broadleaf map, and applied it to the points sampled from the landscape (filtered out anything below 0.5 density).

At this point, I can use “Density filter” nodes to select points within a particular density range, and do stuff to them and spawn meshes eventually.

What I can’t figure out, is how I could use the “density” value (basically the float that is sampled from the texture) to affect things like scaling of the spawned mesh or actual density of meshes spawned in a given area.

Looked for tutorials and documentation but came up empty. Does anyone have a suggestion?

1 Like

I found the answer to one of my questions: how to use the “Density” to scale my meshes.

There’s a blueprint available through “Execute blueprint” node called “Scale by density” and that worked for me.

Here’s the result on the same map, same set of points as before:

This is the graph that got me this far:

Before “Scale by density”:

After “Scale by density”:

By increasing the “Density Exp” parameter in the blueprint, I was able to make the scaling difference more pronounced:

I’m still trying to figure out how to reduce the number of points per square meter based on my plant map. With the blueprint I can make the plants in the darker areas be smaller, but now more of them will be spawned, because more of them fit in a given area.

Here’s the graph result after self-pruning.

I’m thinking that I could extract the “Density” as a float and divide the “Bounds” by it, effectively making the smaller trees have larger bounds and therefore pruning out more of them, but I can’t seem to figure out how to achieve that within the PCG graph.

1 Like