{
 "id": "painterly-animation-meier",
 "title": "Painterly rendering for animation (Meier)",
 "aliases": [],
 "domain": "npr",
 "subdomain": "painterly rendering",
 "stage": "material",
 "realtime": "interactive",
 "platforms": [
  "cpu",
  "desktop-gpu"
 ],
 "year_introduced": 1996,
 "inputs": [
  "mesh",
  "particles",
  "ldr-image"
 ],
 "outputs": [
  "ldr-image"
 ],
 "style": "stylized",
 "dynamic": "dynamic",
 "summary": "Anchors brush-stroke particles to the 3D surface so strokes move with the object, avoiding the shower-door swimming of per-frame 2D painterly filters.",
 "how_it_works": "Particles are scattered over the 3D surfaces, in proportion to their projected area so density in screen space stays near-uniform. Each particle stores a position, colour taken from the lit surface, and stroke attributes. Every frame, the particles are projected, sorted by depth, and each is rendered as a textured, rotated and scaled brush-stroke sprite, with randomised jitter from a reference image. Because particles belong to the geometry, strokes remain consistent as objects and camera move. Stroke size, orientation, and density are controlled per-surface, and ordering along view depth makes paint layering look natural.",
 "when_to_use": "Choose it for painterly 3D animation where frame-to-frame coherence is essential. Prefer `painterly-curved-brush-strokes` for rendering strokes from a single image with curved paths, and `anisotropic-kuwahara` for a cheap screen-space look at the cost of swimming.",
 "cost": {
  "class": "medium",
  "notes": "Scales with particle count; interactive on 1990s hardware, easily real-time on a GPU with instancing."
 },
 "failure_modes": [
  "Stroke popping when particle density changes with distance",
  "Strokes of fixed size look wrong at large zoom",
  "Needs a surface sampling strategy for non-manifold or thin geometry",
  "Per-frame depth sorting of thousands of sprites costs overdraw"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/237170.237288",
   "type": "paper",
   "title": "Painterly rendering for animation",
   "authors": [
    "Barbara J. Meier"
   ],
   "year": 1996,
   "venue": "Proceedings of the 23rd annual conference on Computer graphics and interactive techniques",
   "url": "https://doi.org/10.1145/237170.237288",
   "ids": {
    "doi": "10.1145/237170.237288"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/237170.237288",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/237170.237288",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/237170.237288",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/237170.237288",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/237170.237288",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "meier1996painterly"
  }
 ],
 "presets": [
  {
   "id": "painterly-animation-meier-live",
   "title": "Painterly Animation (Meier 1996) — 2D screen-space shower-door swimming (left) vs 3D surface-anchored brush particles (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_STROKE_DENS": 9,
    "P_BRUSH_LEN": 0.75,
    "P_ROT_SPEED": 0.55,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_STROKE_DENS = 9.00; // P Brush Particle Density [5.0, 15.0, 1.0]\nconst float P_BRUSH_LEN = 0.75; // P Stroke Length [0.3, 1.4, 0.05]\nconst float P_ROT_SPEED = 0.55; // P Object Rotation [0.0, 1.6, 0.05]\nconst float P_SPLIT = 0.48; // P 2D Swim / 3D Anchored [0.0, 1.0, 0.02]\n\nfloat hash21(vec2 p) {\n  p = fract(p * vec2(127.1, 311.7));\n  p += dot(p, p + 34.5);\n  return fract(p.x * p.y);\n}\n\nvec2 rot2(vec2 p, float a) {\n  float c = cos(a);\n  float s = sin(a);\n  return vec2(c * p.x - s * p.y, s * p.x + c * p.y);\n}\n\n// Rotating 3D sculptural still-life (ceramic amphora-torus + flanking fruit spheres)\nvec2 mapStillLife(vec3 p, float t) {\n  vec3 rp = p;\n  rp.xz = rot2(rp.xz, t * 0.75);\n  float d1 = length(rp - vec3(-0.24, 0.02, 0.08)) - 0.34;\n  float d2 = length(rp - vec3(0.32, -0.10, -0.06)) - 0.25;\n  vec2 tq = vec2(length(rp.xz - vec2(0.06, -0.02)) - 0.26, rp.y - 0.20);\n  float d3 = length(tq) - 0.11;\n  vec2 res = vec2(d1, 1.0);\n  if (d2 < res.x) res = vec2(d2, 2.0);\n  if (d3 < res.x) res = vec2(d3, 3.0);\n  return res;\n}\n\nvec3 calcNormal(vec3 p, float t) {\n  vec2 e = vec2(0.0025, 0.0);\n  return normalize(vec3(\n    mapStillLife(p + e.xyy, t).x - mapStillLife(p - e.xyy, t).x,\n    mapStillLife(p + e.yxy, t).x - mapStillLife(p - e.yxy, t).x,\n    mapStillLife(p + e.yyx, t).x - mapStillLife(p - e.yyx, t).x\n  ));\n}\n\n// Evaluate a single painterly oil-brush dab lattice in coordinate space q (2D screen vs 3D surface UV!)\nvec3 evalBrushField(vec2 q, vec3 baseLit, float dens, float strokeLen) {\n  vec2 g = q * dens;\n  vec2 cell = floor(g);\n  vec2 f = fract(g);\n  vec3 bestCol = baseLit;\n  float bestD = 9.0;\n  float bristle = 0.0;\n\n  for (int j = -1; j <= 1; j++) {\n    for (int i = -1; i <= 1; i++) {\n      vec2 nb = cell + vec2(float(i), float(j));\n      vec2 jit = vec2(hash21(nb + 1.3), hash21(nb + 19.7));\n      float ang = (hash21(nb + 41.1) - 0.5) * 1.15 + 0.45;\n      vec2 d = (nb + jit) - g;\n      vec2 dl = rot2(d, ang);\n      // Elongated bristle stroke footprint\n      vec2 scaled = dl * vec2(1.0 / max(strokeLen, 0.25), 2.3);\n      float dist = length(scaled);\n      if (dist < bestD) {\n        bestD = dist;\n        float hueShift = (hash21(nb + 73.9) - 0.5) * 0.22;\n        float valShift = (hash21(nb + 97.1) - 0.5) * 0.16;\n        vec3 dabCol = baseLit * (1.0 + valShift) + vec3(hueShift, -hueShift * 0.4, hueShift * 0.6) * 0.35;\n        bristle = 0.85 + 0.22 * sin(dl.y * 28.0 + hash21(nb + 11.7) * 6.28);\n        bestCol = dabCol * bristle;\n      }\n    }\n  }\n  float dabEdge = smoothstep(0.68, 0.46, bestD);\n  return mix(baseLit * 0.78, bestCol, dabEdge);\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float screenX = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  float dens = clamp(P_STROKE_DENS, 4.0, 16.0);\n  float bLen = clamp(P_BRUSH_LEN, 0.25, 1.6);\n  float t = iTime * max(P_ROT_SPEED, 0.0);\n\n  // Warm Impressionist painted canvas backdrop\n  vec3 bgBase = mix(vec3(0.24, 0.34, 0.46), vec3(0.76, 0.68, 0.52), smoothstep(-0.45, 0.50, uv.y));\n  vec3 col = evalBrushField(uv, bgBase, dens * 0.9, bLen);\n\n  vec3 ro = vec3(0.0, 0.20, 2.08);\n  vec3 rd = normalize(vec3(uv.x, uv.y - 0.04, -1.48));\n  vec3 lDir = normalize(vec3(0.62, 0.74, 0.52));\n\n  float dist = 0.05;\n  vec2 hit = vec2(10.0, 0.0);\n  for (int i = 0; i < 64; i++) {\n    vec2 h = mapStillLife(ro + rd * dist, t);\n    if (h.x < 0.002) { hit = vec2(dist, h.y); break; }\n    dist += h.x;\n    if (dist > 6.5) break;\n  }\n\n  if (hit.y > 0.5) {\n    vec3 p = ro + rd * hit.x;\n    vec3 n = calcNormal(p, t);\n    float ndl = max(dot(n, lDir), 0.0);\n    float rim = pow(1.0 - max(dot(n, -rd), 0.0), 3.0);\n\n    vec3 alb = (hit.y < 1.5) ? vec3(0.92, 0.42, 0.22)\n             : ((hit.y < 2.5) ? vec3(0.22, 0.64, 0.54) : vec3(0.95, 0.78, 0.26));\n    vec3 lit = alb * (vec3(0.24, 0.28, 0.42) + vec3(1.18, 1.08, 0.92) * ndl) + vec3(0.96, 0.88, 0.66) * rim * 0.45;\n\n    if (screenX < split) {\n      // Left: Naive 2D screen-space painterly strokes -> static \"shower-door\" glass swimming over moving 3D form!\n      col = evalBrushField(uv * 1.15, lit, dens * 1.45, bLen);\n    } else {\n      // Right: Meier 1996 3D object-space surface-anchored brush particles -> strokes ride coherently with 3D rotation!\n      vec3 pObj = p;\n      pObj.xz = rot2(pObj.xz, t * 0.75);\n      // Spherical/cylindrical triplanar surface parameterization rigidly locked to the rotating 3D geometry\n      vec2 surfUv = vec2(atan(pObj.z, pObj.x) * 0.42, pObj.y * 1.15 + 0.15 * sin(pObj.x * 3.0));\n      col = evalBrushField(surfUv, lit, dens * 1.35, bLen);\n    }\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));\n  col = mix(col, vec3(0.96, 0.95, 0.90), sep);\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "painterly-animation-meier",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T21:07:21.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.7311,
      "std": 0.0937,
      "min": 0.3529,
      "max": 0.9366
     },
     "image": "/specimens/painterly-animation-meier-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "painterly-curved-brush-strokes",
  "stroke-based-rendering",
  "sillage-brush-splatting"
 ],
 "extends": [
  "stroke-based-rendering"
 ],
 "supersedes": [],
 "combines_with": [
  {
   "id": "sillage-brush-splatting",
   "why": "Same principle: strokes attached to a 3D representation; here they are Gaussian splats."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/npr/painterly-animation-meier.json"
 },
 "solves": [
  "painterly filter swims over moving 3d objects",
  "brush strokes should stick to the surface in animation",
  "per-frame painting causes flicker",
  "painted look with frame-to-frame coherence",
  "shower-door effect in stylised animation"
 ],
 "authority": "Meier, 1996",
 "url": "https://texelatlas.vercel.app/t/painterly-animation-meier/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 25.09,
  "tier": "heavy",
  "p50_ms": 0.8253,
  "p95_ms": 0.8329,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "painterly-animation-meier-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 22.16,
   "tier": "heavy",
   "p50_ms": 0.3523,
   "p95_ms": 0.3602,
   "speedup_x": 2.34,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 18.88,
   "tier": "moderate",
   "p50_ms": 0.5437,
   "p95_ms": 0.5518,
   "speedup_x": 1.52,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}