in shader, Unity3D

Shader Showcase Saturday #3

Share Button

Interactive Grass

Forests and fields have always been present in video games. These environments are particularly challenging to reproduce with high fidelity, mostly due to the fact that the behaviour of grass and leaves is exceptionally complex to capture. There are three main challenges.

Grass Placement

As a rough estimate, there are 250 millions individual blades of grass on a football field. It’s easy to see that placing them individually is simply impossible. Unity itself comes with a simple tool that allows for the placement of grass using bushes to retain some artistic control. However, their solution is pretty limited and does not allow the level of customisation that you might need to produce a more advanced aesthetic. Casey Muratori wrote an interesting article titled The Nebraska Problem, in which he talks about different strategies to place grass procedurally in The Witness.

If you want your game to feature a realistic environment, your best bet is to invest in a tool like Vegetation Studio, which allows placing grass and trees efficiently and effectively.

Wind Simulation

Most plants are light and flexible enough to bend even in the presence of the most gentle breeze. This is a big challenge, because modelling each strand of grass and each leaf using rigid bodies and flexible meshes is simply unfeasible.

If we want a solution that can scale well and be efficient, we have no alternative but to fake it. The most common solution that you can see nowadays in games uses a vertex function to simulate the movement of the grass as if it was affected by wind. Vertex functions operate on the vertices of a model, and can change its shape. Bending a single blade can be done cheaply by moving the X and Z coordinates based on their distance from the ground. This leaves the bottom part unaffected, but gets stronger and stronger the taller the grass is. Many tutorials on this blog cover vertex functions and how to use them. For a gentle introduction, you can refer to the relative section in the article about Physically Based Rendering.

To make sure that each individual blade moves as if affected by wind, most developers use sine waves to generate a so-called wind field. When used properly, wind fields can be very effective in reproducing a believable wind-grass interaction.

For some high-end applications, simulating how wind interacts with each blade requires a fluid simulation. This approach was used in Unity’s most recent interactive experience Book of the Dead (above). In his article Book of the Dead: Photogrammetry Assets, Trees, VFX, Techincal Artist  Zdravko Pavlov explains how his team baked the result of a fluid simulation into a texture atlas. This means that, while exceptionally accurate, their solution could not be changed freely during the game. If you are interested, the forest section seen in the video is available on the Asset Store for free: Book Of The Dead: Environment.

If your game features grass, there are many assets that can help you achieve a consistent and professional look. One of the most popular is Advanced Foliage Shaders v.5, which indeed come with a fully customisable wind animation.

For a non-photorealistic look, Fantasy Adventure Environment is probably the most professional asset you can get, especially if you want that Breath of the Wild feeling for your game.

Object Interaction

Wind is not the only force grass is subjected to. When a character walks on grass, or passes through dense vegetation, we should expect it to move out of the way and then to swing back. Once again, this kind of interaction is often done in the vertex function. MinionsArt published a short video showing how this works. The position of the player is passed to the shader, which uses it to add an outward displacement around that area.

This solution does not scale well, and is only limited to just a few characters. More complex solutions require drawing the interactable objects onto a separate texture, which is then used to control the grass bending. This can also be used to have persistent bending, as it sometimes happens when you walk grass.

From Twitter…

To get you inspired, have a look at these videos that have been recently shared on Twitter.

From the Asset Store…

📧 Stay updated

A new tutorial is released every week.

💖 Support this blog

This websites exists thanks to the contribution of patrons on Patreon. If you think these posts have either helped or inspired you, please consider supporting this blog.


Write a Comment


  1. Hi ! 🙂 Nice read !
    Just some details about the Book of the Dead procedural wind animation.

    You mention fluid simulation, but those are actually not used in the Project released on the Asset Store, and they are actually not used that much in the trailer, in they end they are mainly used to have weaker wind intensity in some areas, like in creases in the terrain, where the grass should be a bit occluded from the wind.

    So it is mostly simple procedural vertex animation, well, with a great shader to bring that alive, but the fluid simulation has only little influence on the scene.

    Best !