Back to projects

2015 · Student project

Grasslands

A Unity3D shader experiment: millions of interactively-cuttable grass blades.

A 2015 student project exploring GPU-driven grass rendering — a custom HLSL shader rendered and cut millions of blades of grass in real time as a 3D character swung a blade through the field.

Unity3DHLSLShader ProgrammingProcedural RenderingGame Development

Grasslands was a 2015 student project exploring how far real-time grass rendering could be pushed with a single HLSL shader in Unity3D. The goal was ambitious for the time: render millions of individual blades of grass on screen, while still letting the player cut through them in real time as they moved a 3D character across the field.

The trick was to describe every blade of grass with a texture instead of tracking it as a separate object. Each pixel of a control texture packed three pieces of information into its colour channels: the red channel stored the blade's height position (from -1 to 1), the blue channel stored the height of the blade itself, and the green channel recorded where — and at what height — the player's blade had swung through the grass. The HLSL shader read all three channels per blade and bent, shortened, or hid it accordingly, so a single swing visibly cut a path through the field.

Because every blade was driven by texture data rather than individual game objects, the shader could render enormous amounts of grass for very little cost — one debug capture shows the field running at over 5,600 FPS with a single draw call. Debug builds also visualised the control texture directly in-engine, overlaying its pixel grid on top of the rendered grass, to check exactly where each splatmap pixel landed and how large it was relative to the blades it controlled.

3D character swinging a blade through a dense field of procedurally rendered grass
Unity performance overlay showing the grass field rendering at over 5,600 FPS with a single draw call
Debug view overlaying the splatmap's pixel grid on the rendered grass to check pixel size and placement
Close-up of the raw channel-encoded control texture used to drive blade height and cutting
Debug view of the blade's cut collision volume alongside the channel visualization
Grasslands | Wiebe Geertsma