Water motion, representation, and light

A convincing interactive stream combines two jobs: deciding how the water changes and calculating what the camera sees. A ripple can change the surface without yet specifying its reflections, and a sophisticated caustics effect can illuminate the riverbed without solving the water's motion.

Consider a proposed clear, shallow stream with submerged plants, a stone and pointer interaction. To understand how a touch becomes an image, follow the information through the system: represent motion, turn it into surface shape or shading directions, then calculate the optical effects. This was a design exploration, not an implemented or benchmarked stream.

Decide what motion the model remembers

A continuous current and a short-lived ripple are different parts of the scene. A scrolling texture can suggest uniform drift. An authored flow map stores a direction and speed at different locations, so the pattern can bend around a fixed stone. It does not derive that circulation automatically or react to a moved obstacle without additional rules. A flow solver evolves motion using forces and configured boundaries. Flow maps

For a pointer disturbance, one approach evaluates a wave directly from the touch position and elapsed time. An expanding ripple can decay as it travels, and several ripples can be added: reinforcement and cancellation are supported by linear superposition. A simple expanding-ring recipe is only one example of direct wave formulas, not the limit of what analytic methods can describe. GPU Gems: prescribed waves

The code examples below describe implementations inspected in September 2026; the linked branches may change.

A wave grid instead remembers surface state and updates it repeatedly. In Evan Wallace's water example, each grid sample stores height and vertical velocity. Differences from neighboring heights change velocity; velocity changes height; damping gradually removes motion. A short source excerpt makes the sequence visible (info.r is height and info.g is vertical velocity):

info.g += (average - info.r) * 2.0;
info.g *= 0.995;
info.r += info.g;

A touch changes that stored state. Later updates spread the disturbance through neighboring samples, so the current state accumulates its history without retaining every old pointer event. Both this approach and direct evaluation use formulas. Their practical distinction is repeatedly evolving remembered state versus evaluating a wave at a requested time.

Direct formulas can be convenient for a few isolated disturbances; a grid can suit persistent, irregular input and local boundary conditions. Neither handles a stone automatically. A grid also introduces resolution, time-step and numerical-error tradeoffs, so it is not inherently more physical or better.

A single height at each horizontal location cannot represent an overturning surface. Shallow-water models also track depth and horizontal motion, supporting bulk flow under their assumptions. Three-dimensional fluid models use volume cells, moving parcels or hybrids to represent splashes and changing topology, with greater computational and implementation demands. Broad ocean motion can also be constructed from sums of waves or spectra evaluated with a fast Fourier transform; local obstacles still require additional treatment. Shallow-water and surface-wave research, Position Based Fluids, David Li's wave implementation

Turn motion into shape and shading directions

The renderer needs a visible surface. Displacement moves mesh vertices using a height texture or formula, changing actual shape, outline and geometry-based overlap. Matching normals must be supplied or calculated; changing vertex positions does not necessarily update them automatically. A separate collision or buoyancy model is not automatically updated either.

A normal is a direction perpendicular to a surface patch. Lighting calculations can use a shading normal that differs from the actual triangle's orientation. A normal map stores such directions in RGB channels: its displayed colors are encoded data, not the water's color. Scrolling or blending these maps changes the lighting directions while vertices stay in place. In a shader that uses those directions for reflection and refraction, that can move glints and distort the view underwater. Normal mapping, Three.js normal and displacement maps

Use displacement when a change should affect the waterline, silhouette or overlap; use normal detail for small ripples whose main effect is optical. They can operate together at different scales. Either can be authored or derived from the same simulated heightfield: positions versus shading directions is a separate choice from animation versus simulation.

A texture is simply a grid of stored samples. In these systems its channels may represent heights, velocities, positions or brightness rather than an ordinary color image. This explains how a motion texture can supply data to several later rendering steps.

Calculate what the light reveals

Surface glints, reflections, refraction and underwater caustics are distinct effects. Their accuracy can be chosen independently of the motion model.

A static environment image supplies reflected surroundings and still responds to the camera and surface orientation, but it cannot include new local motion. A planar reflection renders the scene from a mirrored camera, allowing moving objects at added cost under a flat-plane assumption. Geometric reflected rays query scene shapes; screen-space alternatives are limited to information already recorded on screen. Three.js Reflector

Refraction bends transmitted light. A changing surface can redirect that light onto the riverbed, concentrating it into caustics. Martin Renou's caustics implementation concentrates on this underwater illumination rather than introducing a new fluid solver.

Its EnvironmentMap records scene positions and depth from the light's viewpoint. The caustics vertex shader advances bent rays through that recorded representation to locate receiving surfaces. The fragment shader estimates concentration from the ratio of source area to receiving area. Texture resolution, incomplete visibility and a bounded search limit the approximation. This EnvironmentMap is a scene-data representation, distinct from the sky image often given the same name in reflection workflows.

For the proposed stream, an authored current, interactive ripple grid and environment reflections could be combined. Plants could use prescribed bending or springs driven by that current; explicit boundaries would couple water behavior to stones. Caustics could then be added as an optical effect. None of those choices alone provides the others. The material-response versus transport distinction is developed further in PBR and path tracing.

Compare geometry, texture and screen cost

Distinguish three resolutions: vertices/triangles define geometry; texels store texture samples; drawing-buffer pixels determine much of the visible shading workload. Displacement is usually calculated at vertices. Normal-map data is sampled while shading fragments, approximately per covered pixel in a simple pass. Both approaches still require pixel shading. Vertex normals can be interpolated within triangles, so one triangle does not mean one lighting value.

Calculated example, not a benchmark: a 10 m square viewed straight on, filling 1024×1024 drawing-buffer pixels, with one normal-map tile across it:

RepresentationSample spacingGeometry or stored samples
1024×1024 normal map9.765625 mm per texel1,048,576 direction samples; can shade a plane of 4 vertices/2 triangles
128×128 mesh cells78.125 mm between vertices16,641 vertices; 32,768 triangles
1024×1024 mesh cells9.765625 mm between vertices1,050,625 vertices; 2,097,152 triangles

Dense versus coarse mesh: 64× triangle count and about 63× unique vertices. At unchanged coverage, both have about 1.05 million nominal covered pixels per pass; small-triangle overhead, overdraw, antialiasing, and helper invocations can change actual fragment work. A one-map shader requests about 1.05 million filtered normal samples, not necessarily that many individual texel reads. These quantities cannot be converted into a universal FPS ratio.

Texture animation can scroll existing data without regenerating it. Generating a 1024² normal texture adds roughly 1.05 million output-texel calculations per generation pass. Doubling both texture dimensions quadruples storage/generation work, but does not automatically quadruple sampling time at fixed screen coverage. Doubling mesh divisions quadruples triangle count; doubling drawing-buffer width and height quadruples pixel count.

There is no standard triangle size. It depends on desired feature size, projection, and mesh density. Several samples are needed across a ripple; sample spacing is not a guarantee of a resolved feature of that width. A normal map only contains finer detail if its data actually contains finer variation.

Sources: WebGL pipeline, texture filtering, Three.js PlaneGeometry, GPU performance, WebGL performance guidance. The counts are arithmetic comparisons; no GPU timings were measured.

Choosing a combination for the stream

Priorities below apply to the proposed clear, shallow stream with plants and pointer interaction; they are not universal requirements for every water scene.

ResponsibilityPriority and available approaches
Spatial structureEssential: surface location and depth relative to riverbed/objects. Use a simple depth field or scene geometry; a simulated three-dimensional fluid volume is optional.
Surface shape and fine detailEssential: flat mesh with animated normals, displaced mesh with prescribed waves, evolving heightfield, or reconstructed volume surface. Normals describe optical tilt; geometry describes actual shape.
Continuous currentEssential for this stream: authored direction/speed field or computed flow. An authored map does not automatically respond to moving obstacles.
Pointer disturbancesEssential to the brief: scripted ripple formulas, stateful wave-grid propagation, or a more complete fluid solver. Disturbances should have consistent strength, spread, and decay.
Reflection and refractionEssential visual cues: environment/planar reflections and angle-dependent blending; screen distortion or geometric ray intersections for transmission. Their detail and accuracy can vary independently from motion fidelity.
Body, clarity, and colourEssential optical result: tint as a shortcut, depth as a path-length proxy, or distance-based attenuation. Full volumetric scattering is conditional on haze/light shafts.
IlluminationEssential: coherent sun/environment direction, surface highlights, and object lighting/shadows where relevant. Glints follow surface orientation.
Plants and contactsEssential visible behaviour: prescribed bending or springs driven by the current. Explicit masks/boundaries can stop water passing through stones; full two-way coupling is optional.
Underwater causticsOptional enhancement: animated pattern, surface-driven projected light, or more general light transport. Value depends on sunlight, clarity, and the receiving surfaces.
Foam, spray, bubbles, floating debrisOptional or scene-dependent: textures, particles, simple buoyancy, or volumetric simulation.

Cross-cutting requirement: coherent scale and timing, stable propagation, plausible visible boundaries, and smooth interaction. Techniques can be hybridized; greater simulation fidelity alone does not ensure a better image.