Skip to content

Vegetation Demo

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

  • GPU Instancing - Render thousands of instances efficiently
  • Wind Animation - Procedural wind affecting all vegetation
  • Height Variation - Natural size variation
  • Color Variation - Subtle color differences
  • Terrain Following - Vegetation placed on terrain surface
  • Level of Detail - Reduced complexity at distance
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>
);
}
ControlAction
Left Click + DragRotate camera
ScrollZoom in/out
UI SlidersAdjust vegetation parameters
ParameterEffect
countNumber of instances
spreadDistribution radius
windSpeedWind animation speed
windStrengthAmount of wind bending
heightVariationRange of height differences
colorVariationRange of color differences
  • Uses InstancedMesh for efficient rendering
  • All animation calculated in vertex shader
  • No CPU overhead per instance
  • Demo maintains 60fps with 15,000+ instances
PlatformGrassTreesRocks
Mobile5,000200100
Desktop15,000500200
High-end50,0002,000500