---
id: "stroke-based-rendering"
title: "Stroke-based rendering"
domain: "npr"
stage: "post"
realtime: "offline"
platforms: [cpu, python, desktop-gpu]
year_introduced: 1990
inputs: [ldr-image, mesh, curves]
outputs: [ldr-image, curves]
style: "stylized"
dynamic: "both"
cost: "offline"
authority: "Hertzmann, 2003"
url: "https://texelatlas.vercel.app/t/stroke-based-rendering/"
sources_verified_at: "2026-11-29"
---
# Stroke-based rendering (Hertzmann, 2003)

> Umbrella family that builds an image by placing discrete marks such as brush strokes, stipples or hatches, selected by a rule, an optimisation, or a learned model.

## Reach for it when

- unsure which painterly approach to pick
- want images made of strokes, stipples or hatches
- turn a photo into discrete brush marks
- compare ways to build an image from marks
- non-photorealistic rendering from placed primitives

## How it works

Every method in the family defines a stroke model (position, orientation, size, colour, texture), a source of guidance (an image, a 3D scene, a depth map) and a placement strategy. Greedy approaches pick strokes where the canvas differs most from a target; optimisation approaches minimise a loss between the rendered strokes and the source, sometimes with differentiable rasterisation; particle approaches attach strokes to 3D surfaces. Orientation fields, from gradients, a structure tensor or user input, give coherent direction. Ordering and layering (big to small, dark to light) control the final appearance. The survey organises the field by these decisions.

## When to use it

Choose it as the conceptual map when picking between painterly options. Use [Painterly rendering with curved brush strokes](https://texelatlas.vercel.app/t/painterly-curved-brush-strokes.md) for a classic greedy implementation, [Painterly rendering for animation (Meier)](https://texelatlas.vercel.app/t/painterly-animation-meier.md) for 3D coherence, [Gaussian splats drawn as brush marks](https://texelatlas.vercel.app/t/sillage-brush-splatting.md) for brush marks on a Gaussian splat scene, and [Anisotropic Kuwahara filter](https://texelatlas.vercel.app/t/anisotropic-kuwahara.md) when a filter is enough.

## Cost

offline — Varies; typical algorithms are offline, with GPU variants interactive.
Measured GPU Weight: 11.53× baseline (moderate) — 0.3795 ms median / 0.3961 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 10.03× baseline (moderate) — 0.1595 ms median (2.38× faster on L4).
Ampere A100 scaling: 7.15× baseline (moderate) — 0.206 ms median (1.84× faster on A100).

## Failure modes

- Visual quality depends on stroke placement heuristics, with no single correct answer
- Temporal coherence has to be designed in, not assumed
- Many strokes (tens of thousands) make rendering and sorting heavy
- Optimisation-based methods can converge to blurry local minima

## Dataflow

- Inputs: ldr-image, mesh, curves
- Outputs: ldr-image, curves
- Platforms: cpu, python, desktop-gpu

## Presets

### Stroke-Based Rendering — continuous 3D shading (left) vs curvature-aligned pen hatches, cross-hatching & stipples (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_MARK_DENS": 10,
  "P_HATCH_CONTRAST": 0.85,
  "P_STIPPLE_MIX": 0.45,
  "P_SPLIT": 0.42
}
```

```glsl
const float P_MARK_DENS = 10.00; // P Mark Frequency [5.0, 18.0, 1.0]
const float P_HATCH_CONTRAST = 0.85; // P Ink Contrast [0.3, 1.4, 0.05]
const float P_STIPPLE_MIX = 0.45; // P Midtone Stippling [0.0, 1.0, 0.05]
const float P_SPLIT = 0.42; // P Shaded / Strokes [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);
}

vec2 rot2(vec2 p, float a) {
  float c = cos(a);
  float s = sin(a);
  return vec2(c * p.x - s * p.y, s * p.x + c * p.y);
}

// Classical plaster-cast sculptural form (sphere + torus ring + plinth) for engraving/SBR mark study
vec2 mapBust(vec3 p, float t) {
  float dFloor = p.y + 0.56;
  vec2 res = vec2(dFloor, 1.0);
  vec3 rp = p;
  rp.xz = rot2(rp.xz, 0.35 * sin(t * 0.45));

  float dSph = length(rp - vec3(0.0, 0.02, 0.0)) - 0.40;
  vec2 tq = vec2(length(rp.xy - vec2(0.0, 0.02)) - 0.36, rp.z);
  float dRing = length(tq) - 0.11;
  float dBust = min(dSph, dRing);
  if (dBust < res.x) res = vec2(dBust, 2.0);
  return res;
}

vec3 calcNormal(vec3 p, float t) {
  vec2 e = vec2(0.0025, 0.0);
  return normalize(vec3(
    mapBust(p + e.xyy, t).x - mapBust(p - e.xyy, t).x,
    mapBust(p + e.yxy, t).x - mapBust(p - e.yxy, t).x,
    mapBust(p + e.yyx, t).x - mapBust(p - e.yyx, t).x
  ));
}

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 mDens = clamp(P_MARK_DENS, 4.0, 20.0);
  float contrast = clamp(P_HATCH_CONTRAST, 0.25, 1.5);
  float stipMix = clamp(P_STIPPLE_MIX, 0.0, 1.0);

  // Warm archival cotton drawing paper
  float grain = (hash21(floor(fragCoord * 0.75)) - 0.5) * 0.05;
  vec3 paper = vec3(0.95, 0.92, 0.85) + grain;
  vec3 ink = vec3(0.11, 0.13, 0.18);

  vec3 ro = vec3(0.0, 0.22, 2.15);
  vec3 rd = normalize(vec3(uv.x, uv.y - 0.06, -1.50));
  vec3 lDir = normalize(vec3(0.65 * cos(iTime * 0.35 + 0.5), 0.72, 0.55));

  float dist = 0.05;
  vec2 hit = vec2(10.0, 0.0);
  for (int i = 0; i < 64; i++) {
    vec2 h = mapBust(ro + rd * dist, iTime);
    if (h.x < 0.002) { hit = vec2(dist, h.y); break; }
    dist += h.x;
    if (dist > 7.5) break;
  }

  vec3 col = paper * mix(0.90, 1.0, smoothstep(-0.5, 0.5, uv.y));
  if (hit.y > 0.5) {
    vec3 p = ro + rd * hit.x;
    vec3 n = calcNormal(p, iTime);
    float ndl = max(dot(n, lDir), 0.0);
    float ndv = max(dot(n, -rd), 0.0);
    float spec = pow(max(dot(reflect(-lDir, n), -rd), 0.0), 28.0);
    // Floor contact shadow
    float sh = (hit.y < 1.5) ? smoothstep(0.24, 0.66, length(p.xz - vec2(-0.12, -0.05))) : 1.0;
    float tone = clamp((0.14 + 0.82 * ndl) * sh + spec * 0.28, 0.0, 1.0);

    if (screenX < split) {
      // Left: Continuous grayscale sculptural lighting reference
      col = mix(vec3(0.14, 0.16, 0.20), vec3(0.93, 0.91, 0.87), tone);
      if (hit.y < 1.5) col = mix(paper * 0.92, col, exp(-hit.x * 0.16));
    } else {
      // Right: Discrete Stroke-Based Rendering (curvature-oriented hatches + cross-hatch + stipples + contour!)
      // Surface-aligned stroke coordinates following principal surface curvature
      vec2 sc = (hit.y < 1.5) ? (p.xz * 1.4) : vec2(atan(n.z, n.x) * 0.55, asin(clamp(n.y, -1.0, 1.0)) * 0.95);
      float freq = mDens * 2.8;

      // Layer 1: Primary pen hatching strokes (engaged below tone < 0.78)
      float h1Wave = abs(sin(sc.x * freq + sc.y * freq * 0.35 + 0.6 * sin(sc.y * 5.0)));
      float h1Thick = clamp((0.78 - tone) * 1.35 * contrast, 0.0, 0.92);
      float hatch1 = smoothstep(h1Thick + 0.08, h1Thick - 0.06, h1Wave) * step(tone, 0.80);

      // Layer 2: Cross-hatching strokes at 60 deg (engaged in mid-deep shadows tone < 0.48)
      float h2Wave = abs(sin(sc.y * freq * 1.15 - sc.x * freq * 0.55));
      float h2Thick = clamp((0.50 - tone) * 1.65 * contrast, 0.0, 0.92);
      float hatch2 = smoothstep(h2Thick + 0.08, h2Thick - 0.06, h2Wave) * step(tone, 0.52);

      // Layer 3: Stipple dot marks in highlight-to-midtone transition (0.42 < tone < 0.88)
      vec2 stGrid = fragCoord * (0.14 * mDens * 0.12 + 0.12);
      vec2 stCell = floor(stGrid);
      vec2 stF = fract(stGrid) - 0.5;
      vec2 stJit = (vec2(hash21(stCell + 3.1), hash21(stCell + 19.7)) - 0.5) * 0.55;
      float stR = clamp((0.86 - tone) * 0.48, 0.0, 0.36);
      float stipple = smoothstep(stR + 0.06, stR - 0.04, length(stF - stJit)) * stipMix * step(tone, 0.88);

      // Silhouette ink contour stroke around grazing edges
      float contour = (hit.y > 1.5) ? smoothstep(0.32, 0.14, ndv) : 0.0;

      float inkCoverage = clamp(max(max(hatch1, hatch2), max(stipple, contour)), 0.0, 1.0);
      // Warm sepia/cobalt wash tint under strokes
      vec3 wash = mix(vec3(0.84, 0.80, 0.74), paper, smoothstep(0.15, 0.75, tone));
      col = mix(wash, ink, inkCoverage * 0.92);
      if (hit.y < 1.5) col = mix(paper * 0.94, col, exp(-hit.x * 0.16));
    }
  } else if (screenX >= split) {
    // Light atmospheric sky hatch lines on paper background
    float skyH = smoothstep(0.08, 0.02, abs(sin(uv.y * mDens * 5.0 + 0.25 * sin(uv.x * 6.0)))) * smoothstep(0.05, 0.55, uv.y) * 0.16;
    col = mix(col, vec3(0.24, 0.34, 0.48), skyH);
  }

  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
  col = mix(col, vec3(0.12, 0.14, 0.18), sep);
  fragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
}
```

Attribution: MIT — written for this index.

## Lineage

- extended by [Painterly rendering for animation (Meier)](https://texelatlas.vercel.app/t/painterly-animation-meier.md)
- extended by [Painterly rendering with curved brush strokes](https://texelatlas.vercel.app/t/painterly-curved-brush-strokes.md)

## Sources

1. [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. "Stroke-based rendering." https://texelatlas.vercel.app/t/stroke-based-rendering/ (accessed 2026-12-01).
