Lounging by the Pool

A simple water surface effect.

This water effect uses two heightmaps to keep track of the height of the water surface at instant \(t\) and \(t-1\). Each frame, the current heightmap is used to propagate the waves and produce the next heightmap. The current and next heightmaps are then swapped.

The normal to the water surface is then used to compute the refraction of the light ray coming vertically at the surface, and the refracted ray is used to sample a background texture (here a blue checkerboard pattern). The same surface normal information allows to compute the reflection ratio, which is used to adjust the “brightness” of the surface by blending the sampled color with the white light color.

The initial heightmap is filled with some smooth randomness, creating the initial pool waves. Clicking on the surface then creates additional waves by adding a narrow gaussian to the current heightmap.