NatureGL Grassv1.1.0

naturegl-grass v1.1.0

Grass that runs to the horizon

Instanced GPU grass for three.js on any terrain you describe. Chunked LOD tiles follow the camera, one wind field moves the whole scene, and anything you register flattens the blades as it passes.

$ npm install && npm run dev

#Your terrain. Your scene. Our blades.

You pass a height function and bounds. The grass bakes them once, then adds three instanced ring meshes to your scene. grass.update(dt) runs the offscreen passes, and your render loop stays renderer.render(scene, camera).

Follow the quick start or see how the rings work.

The demo's ball is registered with addTrampler(ball, 0.95). The blades flatten along its path, lean the way it rolled, and spring back over a few seconds.
blades drawn on high
~0.48 M
blades drawn on ultra
~0.96 M
LOD rings, one draw call each
3
presets, one file each
7

#What's in the box

#Seven looks, ready to load

Every preset is a plain object in src/config/presets/: a grass section, a wind section, and staging hints the demo uses.

MeadowmeadowMid-morning spring grass, light fog, a scatter of flowers.
Golden HourgoldenLow sun at 17:36 behind the blades, stronger translucency.
Windy HillswindyTall grass on steep hills, strong gusts and gust sheen.
AutumnautumnRusset grass, orange leaves and falling-leaf drift.
Dry SavannasavannaSparse, clumped dry grass, warm haze and flat acacias.
Night Firefliesnight22:30 under the moon, with fireflies over the field.

See all seven presets

#A field in a few lines

main.js
import * as THREE from 'three';
import { GrassSystem } from 'naturegl-grass';

const heightAt = (x, z) => 1.5 * Math.sin(x * 0.08) * Math.cos(z * 0.06);
const terrain = { heightAt, bounds: [-100, -100, 100, 100] };

const grass = await GrassSystem.create({ renderer, scene, camera, terrain, preset: 'meadow' });
grass.bindLights(sun, hemi);            // sun, ambient and the sun's shadow map
grass.patchTerrainMaterial(groundMat);  // turf colour on your ground, no LOD ring
grass.addTrampler(player, 0.8);

renderer.setAnimationLoop(() => {
  grass.update(timer.getDelta());
  renderer.render(scene, camera);
});

#Gusts you can see

windy: wind speed 1.6, gust 1.2. Bent blades show their paler side, so each gust front reads as a wave of light moving downwind.

#Part of the NatureGL series

NatureGL Grass takes its light from NatureGL Sky and hands its wind and terrain to the rest of the series. NatureGL Island builds its meadows with it.