---
id: "flow-map-water"
title: "Flow-map water animation"
aliases: [flowmap, flow mapping, river flow shader, two-phase flow blend]
domain: "volumes"
stage: "volume"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot]
year_introduced: 2010
inputs: [texture]
outputs: [normals, texture]
style: "both"
dynamic: "dynamic"
cost: "cheap"
authority: "Vlachos"
url: "https://texelatlas.vercel.app/t/flow-map-water/"
sources_verified_at: "2026-11-29"
---
# Flow-map water animation (Vlachos)

> Animate water along authored directions by scrolling a normal map through a flow texture, using two time-shifted layers cross-faded so the reset of the distortion is hidden. Gives rivers, whirlpools and fountains cheaply.

## Reach for it when

- river water should flow along a bend
- water texture stretches and smears when scrolled
- want cheap flowing water without a simulation
- pulsing visible when looping flowing normal maps

## How it works

A flow map is a texture whose red and green channels hold a 2D flow vector per texel, painted or simulated for a river bend, eddy or waterfall. Distorting a normal map by a flow vector that grows over time stretches the pattern without bound, so the technique resets the distortion periodically.

The lookup works with two phases. Compute `phase0 = fract(t / T)` and `phase1 = fract(t / T + 0.5)`. For each phase, sample the water normals at `uv - flow * phase * strength`. Blend the two samples with weight `abs(1 - 2 * phase0)`, so each layer is fully visible at the middle of its cycle and invisible at its reset, where distortion is largest and the jump happens.

Adding a per-pixel noise offset to each phase breaks the visible pulsing; a small per-layer UV offset avoids repeating bands. Flow speed can also modulate normal-map scale and foam. Results feed refraction, reflection and specular shading of the water surface.

## When to use it

Choose it for rivers, streams, pools with currents, spillways and any surface where the flow direction is authored and cheap animation matters.

Prefer [gerstner-waves](gerstner-waves) or [fft-ocean](fft-ocean) for open water where waves propagate and displace geometry. Prefer [shallow-water-equations](shallow-water-equations) or [stable-fluids](stable-fluids) when the flow must react to obstacles and player interaction, and render the simulated velocity through the same two-phase blend. Use [water-caustics-realtime](water-caustics-realtime) and [planar-reflections-oblique-clipping](planar-reflections-oblique-clipping) for the surrounding water look.

## Cost

cheap — Two normal-map fetches and one flow-map fetch per pixel; no simulation.
Measured GPU Weight: 8.5× baseline (moderate) — 0.2795 ms median / 0.4756 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 7.83× baseline (moderate) — 0.1245 ms median (2.24× faster on L4).
Ampere A100 scaling: 6.17× baseline (moderate) — 0.1778 ms median (1.57× faster on A100).

## Failure modes

- Visible pulsing at the cycle period if the two phases are not offset or noise-jittered
- Smearing and stretching of the pattern in regions where the flow is strong relative to the cycle length
- Discontinuities when the flow map has seams or its resolution is too low, since bilinear filtering of vectors cancels opposing flows
- Flow does not interact with objects dynamically unless the map is updated at runtime
- Normal-map detail that is anisotropic looks wrong when rotated by a changing flow direction
- Foam and shoreline masks need separate authoring, or they remain static while the water moves

## Engine support

- threejs: official — `import { Water } from 'three/addons/objects/Water2.js' (flowMap option)` (evidence: https://github.com/mrdoob/three.js/blob/r187/examples/jsm/objects/Water2.js, checked 2026-12-01)
- unity: builtin — `HDRP Water System > Current Map / water decals` (evidence: https://github.com/Unity-Technologies/Graphics/blob/557f6ac22b948284f57ffae6a789751fd1f63620/Packages/com.unity.render-pipelines.high-definition/Documentation~/water-create-a-current-in-the-water-system.md, checked 2026-12-01) — HDRP water currents.
- unreal: builtin — `Material Functions > Misc > FlowMap material functions for animated UV water flow` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/misc-material-functions-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: texture
- Outputs: normals, texture
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot

## Presets

### Two-phase flow-map water with an eddy (glsl-fragment; rendered 2026-11-29)

```json
{
  "cycle_seconds": 2,
  "strength": 0.35
}
```

```glsl
// Flow-map water: a flow field advects a pattern; two phase-offset layers are cross-faded to hide the reset.
const float CYCLE = 2.0;      // seconds per advection cycle
const float STRENGTH = 0.35;  // how far the pattern travels per cycle
float hash(vec2 p) { p = fract(p * vec2(123.34, 456.21)); p += dot(p, p + 45.32); return fract(p.x * p.y); }
float vnoise(vec2 p) {
  vec2 i = floor(p), f = fract(p); f = f * f * (3.0 - 2.0 * f);
  return mix(mix(hash(i), hash(i + vec2(1, 0)), f.x), mix(hash(i + vec2(0, 1)), hash(i + vec2(1, 1)), f.x), f.y);
}
float ripples(vec2 p) { return 0.6 * vnoise(p * 6.0) + 0.3 * vnoise(p * 13.0 + 7.0) + 0.1 * vnoise(p * 29.0); }
vec2 flowField(vec2 p) {            // a river bend plus an eddy
  vec2 c = p - vec2(0.62, 0.45);
  vec2 swirl = vec2(-c.y, c.x) / (dot(c, c) * 40.0 + 0.5);
  return normalize(vec2(1.0, 0.4 * sin(p.x * 5.0)) + swirl * 2.0);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = fragCoord / iResolution.xy;
  vec2 f = flowField(uv);
  float t = iTime / CYCLE;
  float p0 = fract(t), p1 = fract(t + 0.5);
  float w = abs(1.0 - 2.0 * p0);               // weight of layer 0 (layer 1 gets 1 - w)
  float a = ripples(uv - f * p0 * STRENGTH + 0.0);
  float b = ripples(uv - f * p1 * STRENGTH + 0.37);
  float v = mix(b, a, w);
  vec3 deep = vec3(0.02, 0.18, 0.28), shallow = vec3(0.25, 0.6, 0.62);
  vec3 col = mix(deep, shallow, smoothstep(0.2, 0.9, v));
  col += pow(smoothstep(0.6, 0.85, v), 3.0) * vec3(0.8, 0.9, 0.95);
  fragColor = vec4(pow(col, vec3(1.0 / 2.2)), 1.0);
}

```

Attribution: written for this index; algorithm from the cited Valve talk; basis: 0

## Combines with

- [Stable Fluids](https://texelatlas.vercel.app/t/stable-fluids.md): A simulated velocity field can be baked or streamed as the flow map so water reacts to obstacles.
- [Real-time Water Caustics](https://texelatlas.vercel.app/t/water-caustics-realtime.md): Normals from the blended layers drive the caustic pattern on the river bed.
- [Planar reflections with oblique near-plane clipping](https://texelatlas.vercel.app/t/planar-reflections-oblique-clipping.md): The perturbed normals offset the reflection texture lookup on the water plane.

## Sources

1. [primary] Alex Vlachos Water Flow in Portal 2. SIGGRAPH 2010. https://steamcdn-a.akamaihd.net/apps/valve/2010/siggraph2010_vlachos_waterflow.pdf (verified via http on 2026-11-29)

## Cite this entry

Texel. "Flow-map water animation." https://texelatlas.vercel.app/t/flow-map-water/ (accessed 2026-12-01).
