UE5 Animated Grass

This project shows my implementation of a simple wind animated grass system in Unreal Engine 5.

I made this system without using any wind related node in the material graph,

to dive into the math behind every part of the system and make it parametric too.

Here is the result

This clip shows the final result of this system. It is using a material applied on every mesh, which is simply a vertical square. Each square represents a small grass turf, using a 2D alpha-masked image. These were placed in the scene using the foliage system of Unreal.

The result is a moving grass that follows a certain pattern of wind in a defined direction (roughly bottom-left to top-right in this example). Particularly, all adjacent grass turfs follow a similar motion, preventing them from crossing each other in different directions.

The material and its parameters

There are three four factors influencing how much the grass moves. First the wind direction, a 2D vector on the XY plane. It is then multiplied by the V value of the pixel's UV coordinate, so the higher the pixel on the grass blade, the stronger the effect. This also keeps the root end of the grass static, and give that bending illusion even though the grass is slightly stretched (not really noticeable). After that, a tiling Perlin noise map is used to simulate the gusty aspect of wind. The UV's are offset over time, to create the movement effect, to which we add an offset based on the world position of the sprite to keep that continuity in the motion. There are two parameters available at this stage: the Wind Speed, which scales the time to make the grass move faster or slower, and the Area Of Effect, which represent the distance covered by one tiling of the noise map. Finally, there is a last parameter, Wind Strength, which scales the effect, determining how much deformation is applied to each grass turf.

Comparison with the Simple Grass Wind node

This is the result you can get by using the simple grass wind node in the material. It gives a decent impression of wind, although I find it quite "static". The grass doesn't seem to follow a direction but rather oscillate around a vertical axis. Also, the movement of nearby turfs doesn't feel coherent, as sometimes they move in opposite directions, making them cross each other in a weird way. Finally, some movements feel a bit too abrupt if you want to simulate a smoother wind. With my system, my goal was to fix those flaws, as well as making the system parametric, so it can be adjusted to different situations.

The Simple Grass Wind material layout

For comparison, here is the material using the Simple Grass Wind node. It also uses the V value of the pixel's UV to keep the root end of the grass static and only affect the higher part of the grass.