---
id: "painterly-curved-brush-strokes"
title: "Painterly rendering with curved brush strokes"
domain: "npr"
stage: "post"
realtime: "offline"
platforms: [cpu, python]
year_introduced: 1998
inputs: [ldr-image]
outputs: [ldr-image]
style: "stylized"
dynamic: "static"
cost: "offline"
authority: "Hertzmann, 1998"
url: "https://texelatlas.vercel.app/t/painterly-curved-brush-strokes/"
sources_verified_at: "2026-11-29"
---
# Painterly rendering with curved brush strokes (Hertzmann, 1998)

> Paints an image by laying down curved strokes in layers, from large brushes to small, with strokes placed where the canvas differs from a blurred reference and following image gradients.

## Reach for it when

- turn a photo into a brush stroke painting
- stylized image with visible curved paint strokes
- want a hand painted look with detail where needed
- automatic impressionist rendering of pictures

## How it works

Start from a source photograph. For each brush radius (largest to smallest), blur the reference by that radius and compare it to the current canvas. In grid cells where the difference is large, place a stroke starting at the worst-error point and trace a curve perpendicular to the gradient of the blurred reference, stopping when colour deviates, when the stroke reaches maximum length or when it hits low curvature. Strokes are drawn as thick splines with the colour sampled at their seed. Painting from coarse to fine means broad areas get big brush strokes and only high-detail regions get small ones. Parameters (threshold, curvature filter, jitter) define styles such as impressionist or pointillist.

## When to use it

Choose it when you want an individual stroke-by-stroke painted look from a rendered still with a clear stroke structure. Prefer [Anisotropic Kuwahara filter](https://texelatlas.vercel.app/t/anisotropic-kuwahara.md) for an automatic real-time filter, and [Painterly rendering for animation (Meier)](https://texelatlas.vercel.app/t/painterly-animation-meier.md) when frame coherence for animation matters.

## Cost

offline — Many layered passes on CPU; seconds per image in the original implementation.
Measured GPU Weight: 253.67× baseline (extreme) — 8.3459 ms median / 8.4575 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 204.6× baseline (extreme) — 3.2532 ms median (2.57× faster on L4).
Ampere A100 scaling: 176.19× baseline (extreme) — 5.0744 ms median (1.64× faster on A100).

## Failure modes

- No temporal coherence: strokes re-seed each frame, so animation flickers
- Stroke placement depends on the arbitrary grid and error threshold
- Gradient directions are noisy on textured regions
- Long strokes can wander across edges when the gradient is weak

## Dataflow

- Inputs: ldr-image
- Outputs: ldr-image
- Platforms: cpu, python

## Presets

### Painterly Curved Brush Strokes (Hertzmann 1998) — smooth reference render (left) vs coarse-to-fine gradient-curved impasto strokes (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_BRUSH_SCALE": 1,
  "P_CURVATURE": 0.75,
  "P_IMPASTO": 0.65,
  "P_SPLIT": 0.42
}
```

```glsl
const float P_BRUSH_SCALE = 1.00; // P Brush Size [0.5, 1.8, 0.05]
const float P_CURVATURE = 0.75; // P Flow Curvature [0.1, 1.2, 0.05]
const float P_IMPASTO = 0.65; // P Bristle Impasto [0.0, 1.2, 0.05]
const float P_SPLIT = 0.42; // P Reference / Painted [0.0, 1.0, 0.02]

float hash21(vec2 p) {
  p = fract(p * vec2(127.1, 311.7));
  p += dot(p, p + 34.5);
  return fract(p.x * p.y);
}

// Vibrant sunlit coastal landscape & glowing moon/sun sphere (ideal source photo for Hertzmann curved strokes)
vec3 evalReference(vec2 uv, float t) {
  // Swirled sunset sky gradient
  vec3 skyTop = vec3(0.10, 0.22, 0.48);
  vec3 skyMid = vec3(0.86, 0.44, 0.24);
  vec3 skyLow = vec3(0.98, 0.80, 0.36);
  vec3 col = mix(skyLow, skyMid, smoothstep(-0.08, 0.24, uv.y));
  col = mix(col, skyTop, smoothstep(0.18, 0.55, uv.y));

  // Glowing sun orb
  vec2 sunPos = vec2(0.18 + 0.08 * sin(t * 0.4), 0.22);
  float dSun = length(uv - sunPos);
  col = mix(col, vec3(1.15, 0.96, 0.62), smoothstep(0.14, 0.09, dSun));
  col += vec3(0.95, 0.65, 0.25) * exp(-dSun * 6.5) * 0.45;

  // Rolling cypress hills
  float hill1 = -0.02 + 0.10 * sin(uv.x * 3.8 + 0.6) + 0.04 * cos(uv.x * 8.5);
  if (uv.y < hill1) {
    col = mix(vec3(0.14, 0.34, 0.28), vec3(0.28, 0.56, 0.34), smoothstep(-0.22, hill1, uv.y));
  }
  // Shimmering cobalt water foreground
  float waterLine = -0.14 + 0.02 * sin(uv.x * 6.0);
  if (uv.y < waterLine) {
    float wave = 0.5 + 0.5 * sin(uv.y * 55.0 + uv.x * 8.0 + t * 1.4);
    float sunRefl = exp(-abs(uv.x - sunPos.x) * 7.5) * (0.4 + 0.6 * wave);
    col = mix(vec3(0.08, 0.20, 0.42), vec3(0.18, 0.44, 0.66), wave * 0.6) + vec3(0.98, 0.76, 0.32) * sunRefl * 0.78;
  }
  // Foreground sunlit terracotta archway / sphere silhouette on left-center
  vec2 sp = uv - vec2(-0.14, -0.06);
  float r = length(sp);
  if (r < 0.20) {
    float nz = sqrt(max(0.20 * 0.20 - r * r, 0.0));
    vec3 n = normalize(vec3(sp, nz));
    vec3 l = normalize(vec3(0.65, 0.55, 0.52));
    col = vec3(0.88, 0.34, 0.22) * (0.28 + 0.92 * max(dot(n, l), 0.0)) + vec3(0.25, 0.42, 0.64) * max(-n.x, 0.0) * 0.35;
  }
  return col;
}

float luma(vec3 c) {
  return dot(c, vec3(0.299, 0.587, 0.114));
}

// Compute unit tangent perpendicular to luminance gradient (Hertzmann stroke spline direction!)
vec2 gradTangent(vec2 p, float eps, float t) {
  float gx = luma(evalReference(p + vec2(eps, 0.0), t)) - luma(evalReference(p - vec2(eps, 0.0), t));
  float gy = luma(evalReference(p + vec2(0.0, eps), t)) - luma(evalReference(p - vec2(0.0, eps), t));
  vec2 g = vec2(gx, gy);
  float len = length(g);
  if (len < 1e-4) return normalize(vec2(1.0, 0.25 * sin(p.x * 5.0)));
  return vec2(-g.y, g.x) / len;
}

// Paint one coarse-to-fine layer of curved spline strokes that follow iso-luminance flow lines
vec4 paintLayer(vec2 uv, float gridN, float bRadius, float curv, float impasto, float t, float layerSeed) {
  vec2 g = uv * gridN;
  vec2 cell = floor(g);
  vec4 outPaint = vec4(0.0);

  for (int j = -1; j <= 1; j++) {
    for (int i = -1; i <= 1; i++) {
      vec2 nb = cell + vec2(float(i), float(j));
      vec2 p0 = (nb + 0.15 + 0.70 * vec2(hash21(nb + layerSeed), hash21(nb + layerSeed + 23.7))) / gridN;
      vec3 strokeCol = evalReference(p0, t);

      // Trace 3-segment curved brush spine along perpendicular luminance gradient!
      vec2 tang0 = gradTangent(p0, bRadius * 0.65, t);
      float stepL = bRadius * 1.45 * curv;
      vec2 p1 = p0 + tang0 * stepL;
      vec2 tang1 = gradTangent(p1, bRadius * 0.65, t);
      vec2 p2 = p1 + tang1 * stepL;
      vec2 pm = p0 - tang0 * stepL;

      // Minimum distance from uv to the 3 curved polyline segments
      float minD = 9.0;
      float alongT = 0.0;
      float crossS = 0.0;
      vec2 segA[3];
      vec2 segB[3];
      segA[0] = pm; segB[0] = p0;
      segA[1] = p0; segB[1] = p1;
      segA[2] = p1; segB[2] = p2;
      for (int s = 0; s < 3; s++) {
        vec2 ab = segB[s] - segA[s];
        float ab2 = max(dot(ab, ab), 1e-6);
        float proj = clamp(dot(uv - segA[s], ab) / ab2, 0.0, 1.0);
        vec2 closest = segA[s] + ab * proj;
        float dd = length(uv - closest);
        if (dd < minD) {
          minD = dd;
          vec2 dir = ab / sqrt(ab2);
          crossS = dot(uv - closest, vec2(-dir.y, dir.x)) / max(bRadius, 1e-4);
          alongT = (float(s) + proj) / 3.0;
        }
      }

      // Tapered brush stroke width + bristle texture + impasto rim lighting
      float width = bRadius * (0.72 + 0.35 * sin(alongT * 3.14159));
      float mask = smoothstep(width, width * 0.58, minD);
      if (mask > outPaint.a) {
        float bristle = 0.90 + 0.16 * sin(crossS * 18.0 + hash21(nb + 7.1) * 6.28);
        float relief = 1.0 + impasto * (crossS * 0.22 - abs(crossS) * 0.12);
        vec3 colJit = strokeCol * bristle * relief;
        outPaint = vec4(colJit, mask);
      }
    }
  }
  return outPaint;
}

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 screenX = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  float bScale = clamp(P_BRUSH_SCALE, 0.45, 2.0);
  float curv = clamp(P_CURVATURE, 0.1, 1.4);
  float impasto = clamp(P_IMPASTO, 0.0, 1.3);

  vec3 refCol = evalReference(uv, iTime);
  vec3 col = refCol;

  if (screenX >= split) {
    // Right: Hertzmann 3-layer coarse-to-fine curved brush strokes (large -> medium -> fine error-refinement)
    vec3 canvas = vec3(0.92, 0.89, 0.82) * 0.45 + refCol * 0.55;
    vec4 L1 = paintLayer(uv, 9.0 / bScale, 0.048 * bScale, curv, impasto, iTime, 11.3);
    canvas = mix(canvas, L1.rgb, L1.a);

    // Medium layer paints over regions where canvas differs from reference
    vec4 L2 = paintLayer(uv, 16.0 / bScale, 0.026 * bScale, curv, impasto, iTime, 37.9);
    float err2 = smoothstep(0.04, 0.22, length(canvas - refCol));
    canvas = mix(canvas, L2.rgb, L2.a * (0.45 + 0.55 * err2));

    // Fine detail brush layer only along high-error silhouettes & highlights
    vec4 L3 = paintLayer(uv, 27.0 / bScale, 0.015 * bScale, curv, impasto, iTime, 71.1);
    float err3 = smoothstep(0.06, 0.25, length(canvas - refCol));
    canvas = mix(canvas, L3.rgb, L3.a * (0.35 + 0.65 * err3));
    col = canvas;
  }

  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
  col = mix(col, vec3(0.96, 0.95, 0.90), 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

- extends [Stroke-based rendering](https://texelatlas.vercel.app/t/stroke-based-rendering.md)

## Sources

1. [primary] Aaron Hertzmann (1998) Painterly rendering with curved brush strokes of multiple sizes. Proceedings of the 25th annual conference on Computer graphics and interactive techniques  - SIGGRAPH '98. https://doi.org/10.1145/280814.280951 (verified via crossref on 2026-11-29)
2. [primary] A. Hertzmann (2003) A survey of stroke-based rendering. IEEE Computer Graphics and Applications. https://doi.org/10.1109/mcg.2003.1210867 (verified via crossref on 2026-11-29)

## Cite this entry

Texel. "Painterly rendering with curved brush strokes." https://texelatlas.vercel.app/t/painterly-curved-brush-strokes/ (accessed 2026-12-01).
