Skip to main content

GrassLayer

GrassLayer renders curved blades inside rectangular patches on WebGL2 and WebGPU. Each data row places a patch and controls its height, color, and coverage. The GPU generates a repeatable blade pattern from the patch's seed. Panning and zooming keep the blades in place.

import {GrassLayer} from '@deck.gl-community/layers/wind-layers/grass-layer';

new GrassLayer({
id: 'meadow',
data: [{position: [-122.43, 37.76, 0] as const, seed: 12}],
getPosition: row => row.position,
getSeed: row => row.seed,
getSize: [4, 4],
getHeight: 0.3,
getDensity: 0.8
});

The layer accepts standard deck.gl layer props. With pickable: true, picking returns the patch row.

PropDefaultDescription
getPositionrow => row.positionPatch center in the layer's coordinate system. The supplied elevation sets the blade bases.
getSize[4, 4]Width east and length north in meters.
getHeight0.22Nominal blade height in meters.
getBladeWidth0.025Nominal blade width in meters.
getColor[86, 123, 49, 255]Base color as an sRGB byte tuple.
getDensity1Fraction of the patch's blade budget, from zero to one.
getSeed0Integer from 0 to 16,777,215. Change the seed to vary the blade pattern.
bladesPerPatch1024Blade budget per patch, from 1 to 4096.

| windEnabled | true | Uses the scene’s WindEffect. |

Add new WindEffect({strength: 0.35, direction: 55}) to Deck’s effects for animated wind. The effect’s time prop can freeze a pose for repeatable frames.

A patch represents a level surface. Use each patch's position to place it at the desired elevation. For large areas, submit patches near the camera and use smaller blade budgets as needed.

Try the interactive example.

The layer is also exported from @deck.gl-community/layers/wind-layers.