GEGL Waves Filter Water Ripple Simulation in GIMP
The GEGL Waves filter in GIMP produces realistic concentric water ripples by converting Cartesian image coordinates into radial coordinates, applying a periodic wave equation, and modulating pixel displacement. Through user-defined parameters, the filter calculates Euclidean distance from a designated epicenter, regulates the spatial frequency using the wavelength setting, and diminishes the ripple intensity over distance using the damping factor. This process redistributes source pixels via mathematical displacement mapping to simulate the refraction and surface distortion caused by liquid disturbances.
Radial Coordinate Mapping
To generate circular ripples rather than linear waves, the GEGL Waves filter shifts the reference frame from standard Cartesian coordinates \((x, y)\) to a polar coordinate system centered on a designated origin point \((x_0, y_0)\). For every pixel across the image buffer, the algorithm computes the Euclidean distance \(r\) from the center:
\[r = \sqrt{(x - x_0)^2 + (y - y_0)^2}\]
This radial distance serves as the input variable for subsequent trigonometric wave functions. Because all points sharing an equal distance \(r\) yield identical phase values, the resulting wave crests and troughs naturally form concentric rings expanding outward from the origin.
Wavelength and Periodic Displacement
Once the distance \(r\) is established, the filter determines the phase of the wave using a periodic function—typically a sine or cosine variation. The wavelength parameter (\(\lambda\)) dictates the spatial frequency of the ripples by defining the physical distance between consecutive wave peaks:
\[\text{Phase} = \frac{2\pi \cdot r}{\lambda} + \phi\]
where \(\phi\) represents an optional phase shift. A lower wavelength value packs the wave cycles closely together, simulating high-frequency disturbances like rain falling on still water. Conversely, a higher wavelength spreads the cycles apart, creating broader, gentler swells. The calculated phase determines the magnitude and direction of the vector offset applied to each pixel, shifting its sampling coordinates along the radial axis to mimic optical refraction.
Amplitude Modulation and Damping
Natural water waves lose kinetic energy as they spread over a larger surface area, a physical phenomenon governed by the conservation of energy and fluid friction. The GEGL Waves filter replicates this behavior through its damping parameter.
Damping acts as an attenuation coefficient applied directly to the displacement amplitude \(A\). Without damping, wave peaks would retain constant height infinitely across the canvas. With damping enabled, the effective amplitude \(A(r)\) decays as the radius \(r\) increases:
\[A(r) = \frac{A_0}{1 + k \cdot r} \quad \text{or} \quad A(r) = A_0 \cdot e^{-k \cdot r}\]
In this calculation, \(A_0\) represents the initial peak amplitude, and \(k\) corresponds to the user-selected damping value. Higher damping settings force the amplitude to drop rapidly, restricting the visible ripples to the immediate vicinity of the epicenter. Lower damping settings permit the waves to propagate across the entire canvas with minimal energy loss.
Coordinate Distortion and Resampling
After calculating the final damped displacement vector for a given coordinate, the GEGL engine fetches the color data from the source image at the modified coordinate offset. To prevent jagged aliasing artifacts caused by non-integer pixel coordinate lookups, GEGL employs interpolation methods such as bilinear or bicubic resampling. The final output is an optically convincing concentric ripple pattern that accurately mirrors physical fluid dynamics.