A HLSL shader to generate grass on the terrain.

Starting plane

Using the terrain mesh as input, a vertical plane is generated on each triangle in the geometry pass of the shader.

Shape texture

A basic grass shape is obtained by using an input texture and alpha clipping.

Varying params

To achieve a more nature look, the planes are bended, and parameters like the size, position and angle are randomized.

Wind

The top vertices of the planes are displaced using a pattern texture to create a wind effect.

Grass colors

The biome data is injected as a texture and different colors are drawn depending on the biome of the cell.

Amount of grass

Same with the colors, the biome determines the amount of grass. Some planes are skipped to reduce the amount of grass in the cell.