Home
Guides and examples

Water Demo

Interactive water rendering with Gerstner waves, reflections, and caustics

Realistic water rendering featuring Gerstner wave simulation, Fresnel-based reflections, procedural foam, and underwater caustics.

Live Demo

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

Features Demonstrated

Gerstner Waves Fresnel Reflections Screen-Space Reflections Underwater Caustics Procedural Foam Depth-Based Coloring

  • Gerstner Waves — Realistic wave motion with circular particle paths
  • Fresnel Reflections — Angle-dependent reflectivity
  • Screen-Space Reflections — Real-time scene reflections
  • Underwater Caustics — Light patterns on submerged surfaces
  • Procedural Foam — Foam at wave peaks and shorelines
  • Depth-Based Coloring — Darker color in deeper areas

Code Example

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

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

      <AdvancedWater
        size={500}
        depth={30}
        waveHeight={2}
        reflections
        caustics
        foam
      />

      <OrbitControls />
    </Canvas>
  );
}

Interactive Controls

ControlAction
Left Click + DragRotate camera
ScrollZoom in/out

Key Parameters

ParameterEffect
waveHeightHeight of waves
waveSpeedSpeed of wave animation
reflectionsEnable/disable reflections
causticsEnable/disable caustic patterns
foamEnable/disable wave foam
foamThresholdWave height for foam to appear

Performance Notes

  • Reflections use a lower resolution render target
  • Caustics are calculated efficiently in the shader
  • Disable reflections on mobile for better performance
  • The demo adapts quality based on device capability