Texture Advection for Fluid Flow

The following work is inspired by Qizhi Yu's PhD thesis titled Models of Animated Rivers for the Interactive Exploration of Landscapes.

From a map of shorelines, we construct a static flow in the space between the shores. The space is referred to as river. Triangular patches textured with lava or water patterns are sampled in the river. The vertices of the patches undergo the flow individually. Over time the patches become vastly distorted and fade out. New undistorted patches are introduced in their place.

The results are captured in the video:


After publishing the implementation of the technique, I have received feedback from students at 大连理工大学, Dalian University of Technology/China that the material proved to be useful to them.

Texture Advection for Fluid Flow (Demo with source in C++) textureflow.zip 1.4 MB
When they tell you not to panic,
that's when you run!
John Cusack

Underneath the surface


Resulting animation from flame pattern

To derive a static flow for a given river network, we define a potential function that is constant on each single shore. The total flow between to shores will match the difference in the potential function evaluated on the two corresponding shores.


To derive the flow, we interpolate the potential function in the river using Shepard's formula with coefficient p=2. The formula requires a notion of (minimal) distance for a given point in the river and a shore. We obtain these distance functions by computing shortest paths from each shore to all points in the river. The paths are restricted to the river.



We denote by the interpolation of the potential function in the domain of the river. The point lies in the river. The flow is the vector field defined by the numeric partial differentials . In general, the function is not smooth, thus the partial differentials might be discontinous causing the flow to change direction abruptly. However, is divergence free to emulate incompressable fluid.


To create the visual effect of the flow, we equip planar triangular patches with a random piece of the texture. The texture of the patch fades out into transparency beyond a certain radius r around the center. Beyond a radius of 2r, the patch is transparent.

The verticies of a patch undergo the flow velocity individually. In general, the patch deforms. Since a patch starts consisting of equilateral triangles, we can measure the deformation simply by evaluating the edge lengths of the deformed patch.


To balance the visual appearance and computational load, we ensure that these patches remain separated by at least radius r, and yet are tighly packed. Our sampling algorithm follows the method Fast Poisson disk sampling in arbitrary dimensions by Robert Bridson.

The evolution of such a poisson disk sampling is shown in the animation aside. In case two patches have moved closer than 2r, the more deformed fades out (marked by a red dot) while the less deformed remains a Poisson disc sample (green). The removal of patches might leave a gap that is big enough to contain a new patch. The sampling algorithm detects these gaps and locates a new, undeformed patch at that point. The patch is made to slowly fade into the environment.


Correct blending requires that patches are drawn in the order that they were introduced. To yield appealing results, the texture spectrum and patch radius need to be in tune.

Time always erodes advantage.
Every invention sooner or later leads to a counter invention.
Every success contains the seeds of its own overthrow.
Every hegemony comes to an end.
from the red queen