---
id: "grass-blade-rendering"
title: "GPU grass blade rendering"
aliases: [GPU grass, instanced grass blades, grass geometry shader]
domain: "procgen"
stage: "procedural"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot]
year_introduced: 2004
inputs: [heightfield, texture]
outputs: [mesh, gbuffer]
style: "both"
dynamic: "dynamic"
cost: "medium"
authority: "Pelzer"
url: "https://texelatlas.vercel.app/t/grass-blade-rendering/"
sources_verified_at: "2026-11-29"
---
# GPU grass blade rendering (Pelzer)

> Draws millions of grass blades by instancing a tiny blade mesh, generating position, height, bend and colour per instance in the vertex shader from hashes and a wind field.

## Reach for it when

- need a field of grass that sways in wind
- too many grass blades kill performance
- grass blades look flat from the side
- cheap vegetation for open world terrain

## How it works

Represent one blade as a few quads or a strip of segments with a tapered width. Instance it across the terrain: per-instance data comes from a jittered grid or a compute-shader scatter, so the position is a hash of the cell, snapped to the heightfield. In the vertex shader, derive height, facing direction, lean and colour tint from hashes, then bend the upper vertices with a curve (quadratic Bézier) and add wind as a scrolling noise offset weighted by the vertex height along the blade. Fade out by distance with level-of-detail ring buffers that drop segments, thin out the density and finally swap to a flat ground texture. Lighting uses the terrain normal blended with the blade normal, plus fake translucency and ambient occlusion from height along the blade. Cull instances in a compute pass for large fields.

## When to use it

Choose it for open-world meadows and stylised fields where the camera sees individual blades at close range. Prefer alpha-tested textured cards when grass is distant or low budget, [Octahedral impostors](https://texelatlas.vercel.app/t/octahedral-impostors.md) for trees and larger vegetation, [Plant Ecosystem Distribution Simulation](https://texelatlas.vercel.app/t/ecosystem-plant-distribution.md) for deciding where grass grows, and [GPU-driven rendering](https://texelatlas.vercel.app/t/gpu-driven-rendering.md) once you need indirect draws and GPU culling at scale.

## Cost

medium — Dominated by vertex throughput and overdraw from thin alpha-blended or MSAA-edged blades; density and LOD set the budget.
Measured GPU Weight: 52.21× baseline (heavy) — 1.7176 ms median / 1.8398 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 46.97× baseline (heavy) — 0.7468 ms median (2.3× faster on L4).
Ampere A100 scaling: 35.32× baseline (heavy) — 1.0173 ms median (1.69× faster on A100).

## Failure modes

- Aliasing and shimmer on thin distant blades without MSAA or temporal filtering
- Hard LOD rings pop when density or segment count changes with distance
- Overdraw and over-bright specular if blade normals are not blended with terrain normals
- Wind looks like a sliding pattern when the noise scale does not match blade size and it moves uniformly

## Engine support

- unity: builtin — `Terrain > Paint Details > DetailPrototype with useInstancing = true (GPU-instanced grass and foliage meshes)` (evidence: https://docs.unity3d.com/6000.0/Documentation/ScriptReference/DetailPrototype-useInstancing.html, checked 2026-12-01)
- unreal: builtin — `Landscape material Grass Output node + Landscape Grass Type asset` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/landscape-materials-in-unreal-engine, checked 2026-12-01) — Procedural grass instances spawned from landscape layers.

## Dataflow

- Inputs: heightfield, texture
- Outputs: mesh, gbuffer
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot

## Presets

### GPU grass blades — Bezier curved swaying meadow with wind waves & translucency (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_WIND_SPEED": 1.2,
  "P_BLADE_DENSITY": 1,
  "P_BEND_STRENGTH": 0.78,
  "P_TRANSLUCENCY": 0.85
}
```

```glsl
const float P_WIND_SPEED = 1.2; // P Wind Speed [0.0, 3.0, 0.05]
const float P_BLADE_DENSITY = 1.0; // P Density [0.4, 2.0, 0.05]
const float P_BEND_STRENGTH = 0.78; // P Wind Bend [0.0, 1.6, 0.04]
const float P_TRANSLUCENCY = 0.85; // P Translucency [0.0, 1.8, 0.05]

float hash21(vec2 p) {
  p = fract(p * vec2(234.34, 435.345));
  p += dot(p, p + 34.23);
  return fract(p.x * p.y);
}

float noise2(vec2 p) {
  vec2 i = floor(p);
  vec2 f = fract(p);
  f = f * f * (3.0 - 2.0 * f);
  return mix(
    mix(hash21(i), hash21(i + vec2(1.0, 0.0)), f.x),
    mix(hash21(i + vec2(0.0, 1.0)), hash21(i + vec2(1.0, 1.0)), f.x),
    f.y
  );
}

vec3 aces(vec3 x) {
  x = max(x, 0.0);
  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float px = 1.0 / iResolution.y;

  // Golden-hour sunlit sky with warm horizon haze
  vec2 sunPos = vec2(0.32, 0.24);
  vec3 skyTop = vec3(0.14, 0.34, 0.66);
  vec3 skyHor = vec3(0.95, 0.72, 0.44);
  vec3 col = mix(skyHor, skyTop, pow(clamp((uv.y + 0.12) * 1.5, 0.0, 1.0), 0.65));
  float sunD = length(uv - sunPos);
  col += vec3(1.0, 0.85, 0.52) * exp(-sunD * 4.5) * 0.85;
  col += vec3(1.0, 0.96, 0.86) * smoothstep(0.065, 0.025, sunD) * 2.2;

  float windT = iTime * max(P_WIND_SPEED, 0.0);
  float bendStr = max(P_BEND_STRENGTH, 0.0);
  float dens = clamp(P_BLADE_DENSITY, 0.35, 2.2);
  float transGain = max(P_TRANSLUCENCY, 0.0);

  // Rolling distant meadow hill silhouette
  float hill = -0.04 + 0.055 * sin(uv.x * 2.4 + 0.5) + 0.025 * cos(uv.x * 5.2);
  if (uv.y < hill) {
    float dHill = clamp((hill - uv.y) * 4.0, 0.0, 1.0);
    col = mix(vec3(0.24, 0.38, 0.14), vec3(0.07, 0.14, 0.05), dHill);
  }

  // Render 16 depth-sorted parallax grass strata from far horizon to near foreground
  for (int layer = 0; layer < 16; layer++) {
    float fl = float(layer) / 15.0; // 0 = far, 1 = near
    float depth = mix(0.22, 1.0, fl * fl);
    float baseY = mix(hill - 0.01, -0.56, pow(fl, 1.12)) + 0.025 * sin(uv.x * (2.6 + fl * 1.5) + fl * 4.0);
    float bladeH = mix(0.09, 0.44, fl * fl);

    // Quick vertical culling for layer
    if (uv.y > baseY + bladeH * 1.15) continue;

    float freq = mix(42.0, 11.0, fl) * dens;
    float xCoord = (uv.x + 0.35 * fl) * freq;
    float baseCell = floor(xCoord);

    // Check current and +/- 1 neighbor blade cells so strongly bent blades never clip
    for (int nb = -1; nb <= 1; nb++) {
      float cid = baseCell + float(nb);
      float r1 = hash21(vec2(cid, float(layer) * 19.1));
      float r2 = hash21(vec2(cid * 1.7 + 3.1, float(layer) * 7.3));
      float r3 = hash21(vec2(cid * 2.3 - 1.9, float(layer) * 11.7));

      float hMul = 0.62 + 0.65 * r1;
      float H = bladeH * hMul;
      float yLocal = (uv.y - baseY) / H;
      if (yLocal < -0.05 || yLocal > 1.02) continue;

      float t = clamp(yLocal, 0.0, 1.0);
      float worldX = (cid + 0.15 + 0.7 * r2) / freq - 0.35 * fl;

      // Coherent wind gust wave sweeping across the field
      float gust = noise2(vec2(worldX * 2.2 - windT * 0.85, fl * 2.5 - windT * 0.25));
      float lean = (r3 - 0.42) * 0.12 + (gust - 0.28) * 0.28 * bendStr;
      lean += 0.05 * bendStr * sin(windT * 2.6 + worldX * 7.5 + r2 * 6.28);

      // Quadratic Bezier spine displacement: B(t) = t^2 * lean * H
      float spineX = worldX + lean * H * (t * t + 0.25 * t);
      float dx = uv.x - spineX;

      // Tapered blade width from sturdy stem to sharp tip
      float halfW = (0.011 + 0.013 * fl) * (1.0 - pow(t, 1.35)) / sqrt(max(dens, 0.4));
      float edgeAA = max(px * 1.25, 0.0012);
      float mask = smoothstep(halfW + edgeAA, halfW - edgeAA, abs(dx));

      if (mask > 0.001) {
        // Curved cross-section blade normal + central spine crease
        float across = clamp(dx / (halfW + 1e-4), -1.0, 1.0);
        vec3 nBlade = normalize(vec3(across * 0.65, 0.25 + 0.35 * t, 0.72));
        vec3 lDir = normalize(vec3(sunPos.x - uv.x, sunPos.y - uv.y + 0.35, 0.55));
        float ndl = max(dot(nBlade, lDir), 0.0);

        // Rich chlorophyll palette: deep shaded roots -> sunlit chartreuse tips
        vec3 rootCol = vec3(0.03, 0.11, 0.025);
        vec3 midCol = mix(vec3(0.11, 0.34, 0.05), vec3(0.24, 0.46, 0.08), r2);
        vec3 tipCol = mix(vec3(0.42, 0.62, 0.12), vec3(0.68, 0.72, 0.18), r1);
        vec3 albedo = mix(rootCol, mix(midCol, tipCol, t), smoothstep(0.0, 0.85, t));

        // Root AO + wind wave specular sheen + backlit subsurface translucency
        float ao = mix(0.22, 1.0, pow(t, 0.65));
        float sss = pow(clamp(t, 0.0, 1.0), 1.5) * exp(-length(uv - sunPos) * 1.9) * transGain;
        float spec = pow(max(dot(nBlade, normalize(lDir + vec3(0.0, 0.0, 1.0))), 0.0), 18.0) * 0.38 * (0.4 + 0.6 * gust);

        vec3 bladeCol = albedo * (0.28 + 1.15 * ndl) * ao;
        bladeCol += vec3(0.65, 0.82, 0.14) * sss * 0.95;
        bladeCol += vec3(0.95, 0.92, 0.68) * spec * t;

        // Atmospheric horizon mist on distant layers
        float fog = (1.0 - depth) * 0.55;
        bladeCol = mix(bladeCol, vec3(0.74, 0.66, 0.50), fog);
        col = mix(col, bladeCol, mask);
      }
    }
  }

  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).

## Combines with

- [Plant Ecosystem Distribution Simulation](https://texelatlas.vercel.app/t/ecosystem-plant-distribution.md): Distribution density maps decide where and how thick grass blades spawn before the instancer reads them.
- [GPU-driven rendering](https://texelatlas.vercel.app/t/gpu-driven-rendering.md): Compute culling and indirect draw let huge grass fields render without CPU per-chunk work.

## Sources

1. [primary] Kurt Pelzer GPU Gems ch.7 Rendering Countless Blades of Waving Grass. developer.nvidia.com. https://developer.nvidia.com/gpugems/gpugems/part-i-natural-effects/chapter-7-rendering-countless-blades-waving-grass (verified via http on 2026-11-29)

## Cite this entry

Texel. "GPU grass blade rendering." https://texelatlas.vercel.app/t/grass-blade-rendering/ (accessed 2026-12-01).
