How jeantimex/webgpu-water works
This is an interactive browser-based WebGPU water demo. Users orbit the camera, move a buoyant sphere, and draw ripples; the app updates the GPU heightfield, derives normals and caustics, then renders the pool, sphere, and reflective/refractive water against a cubemap. The graph preserves the README’s simulation and rendering stages. Source excerpts show the main component wiring and several resource relationships; shader-pass sequencing is documented in the README, while unsampled implementation details are not inferred.
Main entry points: main.ts App loop and controls · water.ts Water simulation and rendering · pool.ts Pool renderer · sphere.ts Sphere renderer and geometry
Components 14
Application
- App loop and controls
src/main.ts - Ray casting and math
src/lightgl.ts - Shared types
src/types.ts
Water Simulation
- Water simulation and rendering
src/water.ts
Scene Rendering
- Pool renderer
src/pool.ts - Sphere renderer and geometry
src/sphere.ts - Cubemap loader
src/cubemap.ts
WGSL Shaders
- Wave and normal passes
src/shaders/water - Caustics passes
src/shaders/water - Water surface passes
src/shaders/water - Pool shaders
src/shaders/pool - Sphere shaders
src/shaders/sphere
Other components
- Demo user
- Browser WebGPU
Connections 15
- Demo user → App loop and controls: interacts with
src/main.ts - App loop and controls → Browser WebGPU: initializes
src/main.ts - App loop and controls → Ray casting and math: casts interaction rays
src/main.ts - App loop and controls → Cubemap loader: loads skybox
src/main.ts - App loop and controls → Pool renderer: creates and renders
src/main.ts - App loop and controls → Sphere renderer and geometry: creates and updates
src/main.ts - App loop and controls → Water simulation and rendering: creates and advances
src/main.ts - App loop and controls → Water simulation and rendering: adds ripple drops
src/main.ts - Cubemap loader → Browser WebGPU: uploads cubemap texture
src/cubemap.ts - Water simulation and rendering → Wave and normal passes: runs simulation passes
README.md - Water simulation and rendering → Caustics passes: generates caustics
README.md - Water simulation and rendering → Water surface passes: renders water surface
src/water.ts - Pool renderer → Pool shaders: uses shaders
src/pool.ts - Sphere renderer and geometry → Sphere shaders: uses shaders
src/sphere.ts - App loop and controls → Shared types: uses shared definitions
src/main.ts