Scattering objects on surface and control their density

I managed to make a blueprint that randomly scatters the chosen objects along the surface of the ground. The objects even align to the angle of the surface. The problem is that sometimes the objects spawn too close to each other or even overlap. When a random location gets assigned, I want to be able control how close this point should be from the others.

Basically Im recreating the functionalities of the foliage editor in unreal which I cannot use for this project, because foliage uses instanced meshes which is not supported by mobile devices.

Hope someone knows the answer. Thanks!!

You could either make a for loop to check in an existing array of point to see wether the point you’re creating is within a radius of already existing points.

Or another idea would be to base you scatter on a procedural noise texture instead of a random in bounding box. But I’m not sure exactly how it would work, maybe start at points with value 1, then 0.94 and so on. The increment mixed with noise frequency would kind of be your min distance beetween points.

Or use a custom scatter .otl tool from houdini with houdini engine for unreal ?

HI,
Do anyone tryed to modify this blueprint with texture (for example black and white) for scattering. I have custom scatter made with houdini but baking is a nightmare - it is so slow. It should be simple solution how to spawn(distribute) static mesh by texture mask. Maybe someone have some solution?

Hi,

I know I’m a little bit late to this tread, but It popped up in the search field when I had the same issue so here is my solution to the problems:

To check for collisions you can use these nodes:

First fetch bounds of your scatter mesh:
image
You can then use “Box Overlap Components” to check for collision.
image
Box Pos is the position of the mesh you try to scatter, and Extent should be your Box Extent. For the Object Type “WorldDynamic” seems to work.

Here are some other Overlap nodes that you can use.
image

For sampling a texture you can do this:

The “Sample Texture 2D At UVPositions” is quite slow, so you want to run this as few times as possible. First you can gather all your uv positions that you want to sample in a vector 2D array. Convert the “Array to UV List” and feed into the texture sampler. Convert “Color List” to an Array and you can then sample the RBGA values from the “Color Array”.

This means that you should gather all your spawning points in an Position Array, then sample the color, and at the end spawn your object for each position in your array.

Hope this helps!