Articles/Art
Article Intermediate

Grass and its vertex shader. The sampling position and its impact on the result.

Compare vertex, pivot, and blade-based texture sampling for grass animation, and how each choice changes deformation.

Art Rendering Intermediate Article
Articles grassShadersvegetation Art Intermediate grass Shaders vegetation

Vertex animation when creating grass is a standard procedure that gives it a lively and interesting look. Let’s take wind as an example. In practice, we just have a texture mapped in world space coordinates. The texture value defines the magnitude and/or direction of vertex displacement.

But here’s the question: if we have a static grass mesh, where exactly in space should we sample the wind texture?

Depending on how your asset is built, you have several options that will produce different visual results.

Vertex Position

The simplest option, which can be used if you have a basic, unprepared asset. As sampling coordinates, you simply take the vertex position. Each vertex receives its own displacement value. Individual blades get different displacement magnitudes and phases. The grass feels “rubbery,” fluid. Suitable for objects with very low stiffness, for example fluffy, very soft grass.

Cons: the polygon shape may deform. Your grass blade will not only sway sideways but may also stretch or compress in width. This can be noticeable.

Pivot Position

Also a simple option that works with an unprepared asset. As sampling coordinates, you take the pivot position of the asset. All vertices receive the same displacement. The entire asset moves as a single piece. Works well when you need to convey stiffness or structural integrity. For example, a dry bush or a tuft of grass with a shared root base.

Pivot Position + Blade Offset

This option is only possible with a specially prepared asset. The asset must store the local coordinates of each blade’s base, for example in an additional UV set. In this case, you sample at a position defined as: Pivot Position + Local Offset. Each blade moves individually, creating the illusion that every blade is a separate object. Visually, this can look very nice.

And now the most interesting part.

The options described above can be combined within a single material. In practice, you can blend between sampling positions and tune the result depending on the asset. You might have a stiff dry bush or inflorescence that oscillates as a whole. Or medium-soft grass where you want to show both overall cohesion and individual parts. Or fluffy, airy grass. The shader remains unified, its complexity barely increases, but the result can be very compelling.

I hope this small post helps you create beautiful, lively grass that players will enjoy looking at.