---
id: "screen-space-fluid-rendering"
title: "Screen-space fluid rendering (curvature flow)"
aliases: [particle fluid surface smoothing, screen-space surface reconstruction for fluids, curvature flow smoothing]
domain: "volumes"
stage: "volume"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, unity, unreal]
year_introduced: 2009
inputs: [particles, depth]
outputs: [ldr-image, normals]
style: "photoreal"
dynamic: "dynamic"
cost: "medium"
authority: "Laan et al., 2009"
url: "https://texelatlas.vercel.app/t/screen-space-fluid-rendering/"
sources_verified_at: "2026-11-29"
---
# Screen-space fluid rendering (curvature flow) (Laan et al., 2009)

> Render particle fluids without building a mesh: splat particles as spheres into a depth image, smooth that depth with curvature flow, reconstruct normals and shade it as a refractive liquid with thickness and foam.

## Reach for it when

- rendering thousands of fluid particles without meshing
- particles look like beads instead of a smooth liquid
- need a real time water look for sph particles
- want refraction and thickness absorption on particle fluid

## How it works

Particles from [sph-fluids](sph-fluids), [position-based-fluids](position-based-fluids) or [flip-pic-fluids](flip-pic-fluids) are drawn as point sprites that write the depth of a sphere surface (not a flat disc) into a depth texture. The result is bumpy, one bump per particle.

To make it look like a continuous surface, the depth buffer is smoothed in screen space. Curvature flow evolves depth in the direction of mean curvature, which smooths bumps while preserving silhouettes, and it takes a few iterations. Simple alternatives are a bilateral or narrow-range blur that avoids blurring across depth discontinuities.

Normals are reconstructed from the smoothed depth. A second pass accumulates particle thickness additively. Shading then uses these buffers: Fresnel reflection of the environment, refraction offset by normal, Beer–Lambert absorption from thickness, plus specular highlights and optional foam from velocity or density. Only the front surface is represented.

## When to use it

Choose it for real-time rendering of large particle fluids in games and interactive tools, where meshing every frame is too expensive.

Prefer [marching-cubes](marching-cubes) or [surface-nets](surface-nets) on a density grid when you need a real mesh for physics, caustics or offline rendering. Prefer [volume-ray-marching](volume-ray-marching) for smoke, foam-like or translucent media with interior variation. Prefer [shallow-water-equations](shallow-water-equations) or [fft-ocean](fft-ocean) for large open water surfaces rather than free particle volumes. Combine with [water-caustics-realtime](water-caustics-realtime) for light patterns.

## Cost

medium — Cost is dominated by the number of smoothing iterations and the splat fill rate; roughly independent of scene geometry.
Measured GPU Weight: 205.08× baseline (extreme) — 6.747 ms median / 6.8411 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 174.89× baseline (extreme) — 2.7807 ms median (2.43× faster on L4).
Ampere A100 scaling: 150.43× baseline (extreme) — 4.3325 ms median (1.56× faster on A100).

## Failure modes

- Only the nearest surface exists, so back faces, internal bubbles and refraction of other fluid layers are missing
- Blur across silhouettes makes thin streams merge or lose the gap between droplets
- Over-smoothing flattens splash detail, while under-smoothing shows individual particle beads
- Particle size must match spacing; large gaps produce sparse speckled surfaces
- Thickness-based absorption fails for non-convex volumes where thick regions are not along the view ray
- Screen-space result changes with camera distance since the filter radius is in pixels unless depth-scaled

## Engine support

- babylonjs: builtin — `new FluidRenderer(scene); fluidRenderer.addParticleSystem(...)` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/core/src/Rendering/fluidRenderer/fluidRenderer.pure.ts, checked 2026-12-01)

## Dataflow

- Inputs: particles, depth
- Outputs: ldr-image, normals
- Platforms: webgl2, webgpu, desktop-gpu, unity, unreal

## Presets

### Screen-space fluid starting parameters (json-params; parameter preset)

```json
{
  "particle_radius_to_spacing": 1,
  "smoothing_iterations": 40,
  "curvature_flow_dt": 0.0005,
  "depth_clamp_max_pixels": 8,
  "thickness_absorption_rgb": [
    0.4,
    0.1,
    0.05
  ],
  "fresnel_f0": 0.02,
  "refraction_scale": 0.05
}
```

Attribution: parameter preset, sensible defaults chosen for this index

### Screen-Space Fluid Rendering — raw splatted particle spheres (left) vs curvature-flow smoothed refractive liquid (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_CURV_FLOW": 0.88,
  "P_ABSORB_DEPTH": 1.25,
  "P_FLOW_SPEED": 0.95,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_CURV_FLOW = 0.88; // P Curvature Smoothing [0.0, 1.0, 0.05]
const float P_ABSORB_DEPTH = 1.25; // P Beer-Lambert Depth [0.3, 2.5, 0.1]
const float P_FLOW_SPEED = 0.95; // P Pour Speed [0.0, 2.0, 0.05]
const float P_SPLIT = 0.48; // P Particles / Fluid Split [0.0, 1.0, 0.02]

// Procedural pouring stream of 26 animated 3D fluid particles arcing into a swirling basin
vec3 getParticlePos(int i, float t) {
  float fi = float(i);
  if (i < 12) {
    // Pouring stream arc from upper-left spout into basin center
    float ph = fract(t * 0.32 + fi / 12.0);
    float x = mix(-0.78, 0.08, ph) + 0.03 * sin(fi * 4.1 + t * 3.0);
    float y = 0.48 - 0.86 * ph * ph + 0.03 * cos(fi * 3.3);
    float z = 0.06 * sin(fi * 2.7 + t * 2.0);
    return vec3(x, y, z);
  }
  // Swirling turbulent basin pool particles
  float j = fi - 12.0;
  float ang = j * 0.45 + t * 1.15;
  float rad = 0.12 + 0.44 * fract(j * 0.37);
  float x = cos(ang) * rad + 0.16;
  float y = -0.36 + 0.065 * sin(ang * 2.0 + t * 2.5);
  float z = sin(ang) * rad * 0.65;
  return vec3(x, y, z);
}

float smin(float a, float b, float k) {
  float h = clamp(0.5 + 0.5 * (b - a) / max(k, 1e-4), 0.0, 1.0);
  return mix(b, a, h) - k * h * (1.0 - h);
}

// Evaluate either raw unsmoothed spheres (left) or curvature-flow smoothed liquid iso-surface (right)
float mapFluid(vec3 p, float t, float smoothK, bool smoothed) {
  float d = 1e5;
  float r = smoothed ? 0.145 : 0.115;
  float k = smoothed ? (0.16 * smoothK + 0.03) : 0.001;
  for (int i = 0; i < 26; i++) {
    vec3 c = getParticlePos(i, t);
    float ds = length(p - c) - r;
    d = smoothed ? smin(d, ds, k) : min(d, ds);
  }
  return d;
}

vec3 calcNormal(vec3 p, float t, float smoothK, bool smoothed) {
  vec2 e = vec2(0.003, 0.0);
  return normalize(vec3(
    mapFluid(p + e.xyy, t, smoothK, smoothed) - mapFluid(p - e.xyy, t, smoothK, smoothed),
    mapFluid(p + e.yxy, t, smoothK, smoothed) - mapFluid(p - e.yxy, t, smoothK, smoothed),
    mapFluid(p + e.yyx, t, smoothK, smoothed) - mapFluid(p - e.yyx, t, smoothK, smoothed)
  ));
}

vec3 evalPoolBackdrop(vec3 rd) {
  vec2 g = floor(rd.xy * 11.0);
  vec3 tile = mix(vec3(0.10, 0.14, 0.20), vec3(0.18, 0.24, 0.32), mod(g.x + g.y, 2.0));
  return mix(tile, vec3(0.32, 0.52, 0.78), smoothstep(0.0, 0.75, rd.y));
}

vec3 aces(vec3 x) {
  x = max(x, 0.0);
  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float sx = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool showFluid = sx >= split;

  float smoothK = clamp(P_CURV_FLOW, 0.0, 1.2);
  float absorb = clamp(P_ABSORB_DEPTH, 0.2, 3.0);
  float tAnim = iTime * max(P_FLOW_SPEED, 0.0);

  vec3 ro = vec3(0.0, 0.18, 2.22);
  vec3 rd = normalize(vec3(uv, -1.48));
  vec3 col = evalPoolBackdrop(rd);

  float t = 0.05;
  bool hit = false;
  for (int i = 0; i < 60; i++) {
    float d = mapFluid(ro + rd * t, tAnim, smoothK, showFluid);
    if (d < 0.0025) { hit = true; break; }
    t += d * 0.85;
    if (t > 5.5) break;
  }

  if (hit) {
    vec3 p = ro + rd * t;
    vec3 n = calcNormal(p, tAnim, smoothK, showFluid);
    vec3 v = -rd;
    vec3 L = normalize(vec3(0.55, 0.82, 0.58));
    vec3 H = normalize(L + v);

    if (!showFluid) {
      // Left: Raw splatted particle spheres shaded directly (classic bumpy "ball pit" prior to curvature flow)
      float ndl = max(dot(n, L), 0.0);
      float spec = pow(max(dot(n, H), 0.0), 36.0);
      col = vec3(0.16, 0.52, 0.84) * (0.28 + 0.82 * ndl) + vec3(0.95, 0.98, 1.0) * spec * 0.65;
    } else {
      // Right: Screen-space fluid rendering with reconstructed smooth normals, Beer-Lambert thickness absorption, refraction & crest foam!
      // Estimate fluid optical thickness along view ray via 4-step interior march
      float thick = 0.0;
      for (int s = 1; s <= 4; s++) {
        float ds = mapFluid(p + rd * (float(s) * 0.09), tAnim, smoothK, true);
        thick += clamp(-ds * 4.2, 0.0, 1.0) * 0.25;
      }
      vec3 refrDir = refract(rd, n, 1.0 / 1.333);
      vec3 reflDir = reflect(rd, n);
      vec3 refrBg = evalPoolBackdrop(refrDir);
      vec3 trans = exp(-vec3(0.75, 0.22, 0.08) * thick * absorb * 3.8);
      vec3 reflCol = mix(vec3(0.28, 0.54, 0.84), vec3(0.95, 0.98, 1.0), smoothstep(-0.1, 0.7, reflDir.y));
      float fres = 0.03 + 0.94 * pow(1.0 - max(dot(n, v), 0.0), 4.5);
      float spec = pow(max(dot(n, H), 0.0), 96.0) * 2.4;
      // Aerated foam along fast-moving upper crests
      float foam = smoothstep(0.08, 0.42, p.y + 0.25 * n.y) * smoothstep(0.18, 0.02, thick) * 0.45;
      col = mix(refrBg * trans + vec3(0.04, 0.24, 0.34) * (1.0 - trans), reflCol, fres) + vec3(1.0) * (spec + foam);
    }
  }

  float sep = smoothstep(0.0035, 0.0008, abs(sx - split));
  col = mix(col, vec3(0.95, 0.97, 1.0), sep);
  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Lineage

- extended by [Narrow-Range Screen-Space Fluid Depth Filtering](https://texelatlas.vercel.app/t/narrow-range-ssf-depth-filter.md)

## Combines with

- [Position Based Fluids](https://texelatlas.vercel.app/t/position-based-fluids.md): Particle positions from the solver are splatted as the input depth and thickness images.
- [Real-time Water Caustics](https://texelatlas.vercel.app/t/water-caustics-realtime.md): Reconstructed screen-space normals and thickness can drive projected caustics on receiving surfaces.
- [Temporal Anti-Aliasing](https://texelatlas.vercel.app/t/temporal-anti-aliasing.md): Temporal accumulation hides the flicker of per-particle depth bumps.

## Sources

1. [primary] Wladimir J. van der Laan, Simon Green, Miguel Sainz (2009) Screen space fluid rendering with curvature flow. Proceedings of the 2009 symposium on Interactive 3D graphics and games. https://doi.org/10.1145/1507149.1507164 (verified via crossref on 2026-11-29)
2. [talk] Simon Green Direct3D 11 effects (includes screen-space fluid rendering). GDC 2010. https://developer.download.nvidia.com/presentations/2010/gdc/Direct3D_Effects.pdf (verified via http on 2026-11-29)

## Cite this entry

Texel. "Screen-space fluid rendering (curvature flow)." https://texelatlas.vercel.app/t/screen-space-fluid-rendering/ (accessed 2026-12-01).
