Spawning foliage procedurally on Static Mesh

Hello everyone,

Extremely new to unreal and ‘this kinda stuff’ in general. I’m not sure if I’m asking the wrong question almost, but here it goes.

I am making a cracked floor which would have foliage, weeds (etc), popping through it. I have a mask in the material on my static mesh that I can use to specify whats in the cracks, i.e. grass or sand, and the size/intensity/etc. This side of it is fine, but I would like to procedurally spawn weeds where the cracks are, based on the mask. I can’t see how to do this.

In this instance it’s an outside floor, so I could just flatten a ‘Landscape’ and spawn with landscape layers using a ‘grass’ node (as I know how to do that). However, this would still be a problem if I ever wanted to spawn them on a wall or floor in a house, for example, as that’s a static mesh. I could also do it by hand, but there are obvious benefits to having it change as I mess with the mask for more procedurally generated settings.

This person below seemed to be asking the same but never got a response: Painting foliage on SMs based on a texture mask

Am I fundamentally misunderstanding how foliage or materials work, or am I just missing some obvious information? I’ve heard there are multiple ways to do the same this with Unreal so, if anyone knows, a few examples of how to do this with ‘pros’ and ‘cons’ would be great.

Regards!

When using the foliage-painter, it seems the best we can do is use the vertex-channel:

Otherwise, landscape-layers aside, there doesn’t seem to be anything the painter is ‘aware’ of for the mesh(es) it is painting on.

There’s no way to say ‘see texture/mask X’. Vertex-coloring isn’t a bad option though. Meshes can be decently detailed nowadays, and nanite can help there as well.

One thing you might be able to do is have the mesh(es) paint to a runtime-virtual texture. In the grass material, you can read that in, and based on whatever you pick as a mask, use WPO or other techniques to hide/move the grass so it’s just not-drawn anywhere near your game (effectively hidden). IIRC if you move it far enough away it will be culled by the system and never-drawn to begin with.

1 Like

That latter one sounds promising. I have heard/seen of runtime-virtual textures but don’t understand them yet, so will see about watching some videos on it.

Only started looking at Unreal in the last few days, with no prior experience in this games, so all very new to me.