Interactive Grass? (Landscape Grass Type)

Followed this Tutorial How to Create Interactive Grass in Unreal Engine 5 - Step by Step Guide - Stylized Grass (2023) - YouTube

All works fine but one big problem. The Tut is using a Parameter Collection for a single object position, I’m trying to figure out how I can use multiple object locations?

I’ve changed my approach and for future reference is …

However, the Grass is Scaling but I think it should bend. Any suggestions?

You would need to rotate the vertices of the mesh around a point to bend, so they don’t stretch.

If you want a GREAT breakdown on how this might work, heh, check this out: HYPER-REALISTIC Grass Wind Animation [UE4, valid for UE5] - YouTube

Its likely not worth the effort.
You need something (a mesh specifically built to allow it) that allows this kind of behaviour:

If you do it, then you can just use vector fields to displace whatever you want in ehatever shape you want…

Since its based on vectorfields you can even do heavy animated displacement at no extra cost…

(I really should package this up for the marketplace…)

Of note, this would allow infinite levels of interaction. You just render stuff to a vectorfield RT and the grass automagically animates… easy peasy…

Yes! I use the Ray Wenderlich grass/snow tutorials (Creating Interactive Grass in Unreal Engine 4 | Kodeco) but also capture the vector field to displace snow, mud, etc, etc. It’s quite handy, I agree.

Sort of.

The pivot point of each blade of grass in these tutorials is not set, so the deformation will be highly inaccurate.

If you notice (or try and replicate the top gif) you’ll see that the shape of the rectangle is maintained throughout the rotation with minimal distortion (math for this is prone to real low floating point errors since its very small, so there is some deformation).

If you were to attempt to fold over regular rectangles without the right code (or the code in this tutorial), the top plane would sheer off and distort differently than the sides.
That is why you need a specifically built mesh and a blender plugin to generate it.

For grass paritcularly, if you have any sort of complex geometry the code will make a large blob of mess that’s easy to notice upon displacement of larger almost completely flat areas.

The tutorials are a great starting point, particularly as they seem to be updated compared to 3 or 4 years ago when they first came out and included some different/wierder approaches (they could still be there, capturing trails from under the landacape is a no-no for many reasons)…

Another addition to this would be to actually cull grass with the RT. You can output into the alpha to make stuff “disappear”.
Which is great for removing grass when a player places buildable objects on the floor, for instance…

Thanks for the replies so far, however creating Wind is not the same as “interacting” with Grass.

I’ve tried adding VertexNormalWS which does push outward but now a problem masking / isolating it as it’s affecting all the grass.

I sample a normal-map and pan it. Since it’s a vector, you can use it to push patterns into your wind, so if wanted long waves, or bunchy stuff, etc.

There’s also a wind-node built in but it’s el-cheapo and tiles.

You almost always want to make your own, but it basically comes down to noise moving over time, ensuring some differences for each grass. IMHO.

You can use PerInstanceRandom node for some variation as well.

Wind is usually on top of the RT system.

You still need a properly created mesh if you want to use vertex normal based displacement;
You do not if you pan normals instead.

All grass does - at a visible distance - when agitated by wind is change color/hue between lighter and darker based on what blades the sun catches.
That’s why panning a world position normal map into it provides a very decent effect at a super low cost (compared to actually moving verticies).

You could also combine the 2 effects, but they usually go off sync, so sticking to 1 or the other tends to provide more realism.

Vertex normals will affect all the grass. Even the engine simple wind and other things like it (a sine on time into vertex normal ws) will affect everything.

Masking it is kind of pointless since that is the effect you really want.
But, you can sphere mask the area of effect just the same.
Doing so could maybe help on limited GFX systems where vertex movement on large amount of instances causes GPU bottlenecks (a switch?). Realistically, you won’t get all that much of an improvement. The vertex calculations are super quick on the gpu…

Just to clarify I’m not wanting to create a Wind system, there are plenty of tutorials on that but not many for objects interacting with grass.

Interaction should all be done with vector field RTs.

Wind is just on top of that in one of the ways explained just above.

I found a way to mask the effect using Dot Product and a Lerp. It might not be great but has enough affect for me, also decided to combine the scale and bend …

Probably ok.
Couple tips.
Make float 3 is pointless (extra cost for no reason) just make a float 3 parameter to use. You can manipulate the values individually anyway.

DistanceField gradient requires the project to have the proper settings. Remeber this if you ever move the asset.

Generally after you add, multiply etc. Before you feed the value in to a field that uses normalized values you should clamp the values out so they do not exceed 1.
I think this is applied to your vertex, so this wouldn’t necessarily apply.

1 Like