finds.dev← search

// the find

evanw/webgl-water

★ 1,278 · JavaScript · updated Dec 2022

WebGL Water Demo

A single-page WebGL demo by Evan Wallace that renders realistic water with reflection, refraction, and caustics. It's aimed at people who want to see (and steal) the shader math for screen-space water rendering, not at anyone looking for a library or engine.

The whole simulation lives in a handful of readable files (water.js, renderer.js, cubemap.js) with no build step or dependencies to install — you can read main.js top to bottom in a few minutes. The water height-field simulation and caustics projection are genuinely clever techniques that get reused constantly in graphics tutorials and forum answers years later. lightgl.js is a tiny, self-contained WebGL wrapper that's easier to trace through than reaching for three.js just to understand the pipeline.

It targets WebGL1 with immediate-mode-style state management (lightgl.js), so it won't run as-is against anything expecting WebGL2 or a modern renderer without porting. There's no packaging, no npm module, no way to pull just the water simulation into another project — you copy files and untangle globals by hand. Zero tests, zero comments explaining the caustics math, and the README is a single link to a blog post, so understanding intent means reading shader code cold. The OES_texture_float_linear-polyfill.js hints at floating-point texture support gaps that are mostly moot on hardware today, dead weight left over from 2011-era WebGL.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →