Home
Guides and examples

Vegetation Demo

GPU-instanced vegetation with wind animation at 60fps

GPU-accelerated instancing capable of rendering 10,000+ instances of grass, trees, and rocks at 60fps with procedural wind animation.

Live Demo

[https://github.com/jbcom/strata-game-library/tree/main/apps/examples/vegetation-showcase]( View Source Code ) [/getting-started/quick-start/]( Get Started with Vegetation )

Features Demonstrated

GPU Instancing Wind Animation Height Variation Color Variation Terrain Following Level of Detail

  • GPU Instancing — Render thousands of instances efficiently with InstancedMesh
  • Wind Animation — Procedural wind affecting all vegetation in vertex shader
  • Height Variation — Natural size variation for organic appearance
  • Color Variation — Subtle color differences across instances
  • Terrain Following — Vegetation placed on terrain surface
  • Level of Detail — Reduced complexity at distance

Code Example

import { Canvas } from '@react-three/fiber';
import {
  GrassInstances,
  TreeInstances,
  RockInstances,
  ProceduralSky,
} from 'strata-game-library/core';
import { OrbitControls } from '@react-three/drei';

function VegetationDemo() {
  return (
    <Canvas camera={{ position: [0, 30, 50], fov: 60 }}>
      <ProceduralSky sunPosition={[100, 50, 100]} />
      <ambientLight intensity={0.4} />
      <directionalLight position={[50, 100, 50]} intensity={1} castShadow />

      <GrassInstances
        count={15000}
        spread={100}
        windSpeed={1.5}
        windStrength={0.3}
      />

      <TreeInstances
        count={500}
        spread={150}
        minHeight={4}
        maxHeight={12}
      />

      <RockInstances
        count={200}
        spread={120}
        moss
      />

      <OrbitControls />
    </Canvas>
  );
}

Interactive Controls

ControlAction
Left Click + DragRotate camera
ScrollZoom in/out

Key Parameters

ParameterEffect
countNumber of instances
spreadDistribution radius
windSpeedWind animation speed
windStrengthAmount of wind bending
heightVariationRange of height differences
colorVariationRange of color differences

Instance Counts by Platform

PlatformGrassTreesRocks
Mobile5,000200100
Desktop15,000500200
High-end50,0002,000500

Performance Notes

  • Uses InstancedMesh for efficient rendering
  • All animation calculated in vertex shader
  • No CPU overhead per instance
  • Demo maintains 60fps with 15,000+ instances