So Ive been messing around with the Landscape Grass Type function and I cant seem to limit where the grass spawns. My world is a mountain terrain and the grass keeps spawning vertically along the surface.
Is there a way I can limit the grass static mesh to only spawn to a certain area?
PICTURES: UE4 Issue - Album on Imgur
Attached is an album with images of the landscape and the issue Im having. In the album there is a splat map. I would like the grass to only generate on the purple shaded areas. of the splat map.
Any help is appreciated!
It’s just a matter of inputting the correct data into the Landscape Grass node in your material. The Grass node input is evaluated for your entire landscape and values > 0 will have some grass and the larger the number, maxing out at 1, the more grass that will be placed.
If you want only the purple areas, one idea is to take the red and blue channels of the splat map, add them together and multiply by 0.5. That will give you a number between 0 and 1 as to how purple the current area is. You can connect that to the A input of an “If” node. Connect some high constant like 0.9 to the B node. For the “A < B” connect a constant 0 and for “A > B” and “A >= B” connect a constant 1. Then connect that to your Grass input.
This will place grass only when average of both the red and blue channels in the splat map is greater than 0.9.
There are many other possibilities to avoid vertical grass without using the splat map. Your material could check the World Normal Z component and exclude grass when it’s greater a certain number, for example.
Another quick question- with the Landscape Grass Type generator, Im having trouble with collision.
Is there a way to make collision generate automatically as the static meshes generate?
Ive seen tutorials and other people seem to say they either havent figured it out or there is no way to do this.
Hi Carbonology, unfortunately the grass instances exist only fleetingly and get created when nearby the camera and destroyed when you move away, and as such cannot easily have collision enabled without impacting performance.
The main problem is we store only the information required to render the grass instances rather than the full CPU-side data we would need for collision. Creating that data and also enable physics would substantially slow down the grass system.
For gameplay-related foliage requiring collision, I suggest you use the foliage system (either manually or with the new Procedural Foliage placement) which creates actual instances and allows you to configure collision.
Are you looking to block the player with your grass system objects or do you need collision on them for another purpose?
I would also like to have collision on the grass, because I would like to trace against the grass to remove grass instances on runtime, e.g. after I spawn a building, because if I don’t remove the grass and I walk around inside of the building, the grass is going through the floor which is of course looking quite strange. But I understand you need to have best performance on the grass so collision needs to be disabled… But is there any other way to remove grass on runtime?
Ah I see. Ill use a Procedural Foliage Generator for my trees instead. Thanks!
I think the best solution would be to add a new volume type you could spawn at runtime that removes existing grass within it and blocks new grass from being spawned within the volume should you come within range.
I’ve added a feature request for that with ticket number UE-19187.
Hey Jack, will something like a “grass blocking volume” be in 4.10? I guess you can imagine how ugly it looks when grass is coming through the stone or wooden floor and I have not yet found any workaround to avoid this unfortunately.
Hi John, I’m afraid this didn’t make it into 4.10. I’ve updated the ticket to request it for 4.11.
We have limited development resources, and a lot of engine areas to cover, so this hasn’t bubbled up enough in priority compared to other issues and features we’re also working on.
We also have a rapid release schedule and the 4.10 cutoff for new features has already passed.
Oh, thanks for letting me know Is this a feature difficult to put in or is it just not too important for Epic? The grass system itself is really awesome, but how should it be used in dynamic games without any way to remove grass?
Hi Jack! Will the grass blocking volume be in 4.11?
I’m afraid it did not. We’re doing more work on grass for 4.12 though so I’ve raised the priority of this request.