System like the landscape grass

Hey everyone!

I’m trying to create the basics of a system like the built-in landscape grass. Where grass and foliage is automatically spawned on parts that have a specific material.
I’m not using a landscape but I’m generating my map with maptiles during runtime.
I’d like to blend different material functions(grass, dirt, leaves,…) with each other based on a random world space mask. Ideally I would like to influence this mask with where objects are placed. E.g. In a forest there would be less grass where trees are close to each other. However this is an extra. I’m more interested in the first mentioned problem.
I was hoping that material functions would have a physic material slot. This way I could just use a trace. But that is not the case.
If anyone could help me or point me to the right direction would be appreciated!

Cheers

For this you’d want to use the grass tool:

That’s the point. I’m not using a landscape. Those methods only work when you use them on a landscape…

1 Like

there’s already a feature request for this:

so vote!

btw AFAIK the landscape grass system doesn’t have runtime generation either

Cool, voted! :slight_smile:
I already gave up on the landscape grass system, I just want similar results.

I was thinking of maybe checking the color of a texture at a given position.
I check a position, get the material and check which color is at the position in worldspace->uv. Absolutely no idea how I would do this though.
I know some games do something similar for grass color variation. Get the color of the grass texture on the ground and blend them with the grass mesh texture color.

Thanks for the replies!

Oh yes…I see your point. For some reason I thought I had used the grass tool on static meshes before but in testing I can see it fails to spawn them…

In that case, Rama’s plugin allows you to read a texture from within an actor, you could use this to read your mask textures then create static mesh instances and set their world location based off of this data.

Good luck!

Thanks, I’ll take a look at this

Just curious. What is it about the landscape tool that doesn’t suit your needs?

Check the link in my signature. The project I’m working on uses tiles to create maps and not a landscape. Currently I’m just spawning instanced grass on every flat tile. I’d like the grass to spawn correctly only on grass material and not for example dirt or dead leaves :slight_smile:

Ok, I got it to work with Rama’s plugin. I use 2 variables, density and accuracy to control the spawning. It’s pretty heavy and slows down my game a lot during the raycasts and pixel lookup. Not sure how to improve it but I’m glad I got it working.

A quick summary: I do a render target texture of the material. Then I get all the pixels of the saved texture. Then depending on the accuracy I do a line trace every x distance and get the color of the pixel at that location.