Texel A field guide to 3D techniques

Boids flocking × Painterly rendering for animation (Meier)

Brush strokes that flock. A painterly renderer whose strokes swarm, drift and settle like a murmuration while still describing the 3D form. Each stroke particle is a boid tethered to its surface anchor, so one slider moves the look from still painting to living paint.

Open in StudioReproduced556× · 17.2 ms

Boids flockingSimulation · Real-timein: particlesout: particles, animationparticlesPainterly rendering for animation (Meier)Material · Interactivein: mesh, particles, ldr-imageout: ldr-image

Verified proof

reproduced · 2026-12-01wrong-nebulalicense MIT
Specimen render of Flocking brush strokes (left: static Meier anchors, right: tethered Reynolds boids murmuration)
Cross-proof specimen. Flocking brush strokes (left: static Meier anchors, right: tethered Reynolds boids murmuration). Verified WebGL2 proof · 2026-12-01

Split-screen WebGL2 proof comparing rigidly anchored Meier surface brush strokes (left) against tethered Reynolds boid brush sprites combining separation, alignment, cohesion, and an anchor spring so strokes flock into lively impasto murmuration ribbons while preserving 3D still-life form (right).

Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · blends surface-anchored Meier painterly stroke shading with local 3x3 Reynolds boid separation, alignment, and cohesion steering controlled by a single liveliness tether

Show GLSL proof (195 lines)
const float LIVELINESS = 0.82; // P
const float STROKE_DENSITY = 26.0; // P
const float FLOCK_COHESION = 0.72; // P
const float IMPASTO_RELIEF = 0.90; // P
vec2 hash22(vec2 p) {
  vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
  p3 += dot(p3, p3.yzx + 33.33);
  return fract((p3.xx + p3.yz) * p3.zy);
}
// Linear-space analytical 3D still-life reference pass (terracotta orb, cobalt vase sphere, ochre drapery & studio wall)
void sampleLitScene(vec2 p, out vec3 col, out vec2 surfTangent, out float depth) {
  vec3 ro = vec3(0.0, 0.16, 2.35);
  vec3 rd = normalize(vec3(p.x * 1.12, p.y - 0.04, -1.62));
  vec3 L = normalize(vec3(0.68, 0.72, 0.45));
  vec3 L2 = normalize(vec3(-0.78, 0.30, 0.25));
  // Deep ultramarine-to-ochre studio backdrop in linear space
  float drape = 0.5 + 0.5 * sin(p.x * 6.5 + 0.75 * sin(p.y * 4.5));
  col = mix(vec3(0.015, 0.032, 0.088), vec3(0.28, 0.19, 0.09), smoothstep(-0.38, 0.46, p.y + 0.12 * drape));
  col = mix(col, vec3(0.16, 0.06, 0.03), smoothstep(0.06, -0.36, p.y) * (0.45 + 0.55 * drape));
  surfTangent = normalize(vec2(1.0, 0.28 * cos(p.x * 6.5)));
  depth = 5.0;
  if (rd.y < -0.01) {
    float tf = (-0.42 - ro.y) / rd.y;
    if (tf > 0.0 && tf < depth) {
      vec3 fp = ro + rd * tf;
      if (fp.z > -2.6) {
        depth = tf;
        float sh = smoothstep(0.24, 0.65, length(fp.xz - vec2(-0.08, -0.04))) * smoothstep(0.16, 0.48, length(fp.xz - vec2(0.24, 0.24)));
        col = mix(vec3(0.025, 0.018, 0.022), vec3(0.32, 0.18, 0.07), 0.20 + 0.80 * sh);
        surfTangent = vec2(1.0, -0.08 * fp.x);
      }
    }
  }
  // Primary vermilion/cadmium sculpted orb
  vec3 c1 = vec3(-0.06, 0.01, -0.04);
  float r1 = 0.39;
  vec3 oc1 = ro - c1;
  float b1 = dot(oc1, rd), d1 = b1 * b1 - (dot(oc1, oc1) - r1 * r1);
  if (d1 > 0.0) {
    float t1 = -b1 - sqrt(d1);
    if (t1 > 0.0 && t1 < depth) {
      depth = t1;
      vec3 hp = ro + rd * t1;
      vec3 n = normalize(hp - c1);
      float ndl = max(dot(n, L), 0.0);
      float rim = pow(1.0 - max(dot(n, -rd), 0.0), 2.5);
      float spec = pow(max(dot(reflect(-L, n), -rd), 0.0), 14.0);
      vec3 shadowC = vec3(0.032, 0.014, 0.055);
      vec3 midC = vec3(0.62, 0.095, 0.025);
      vec3 hiC = vec3(0.96, 0.56, 0.07);
      col = mix(shadowC, midC, smoothstep(0.02, 0.54, ndl));
      col = mix(col, hiC, smoothstep(0.54, 0.96, ndl));
      col += vec3(0.06, 0.22, 0.54) * rim * max(dot(n, L2), 0.0) * 0.90 + vec3(1.0, 0.88, 0.56) * spec * 0.65;
      vec2 rad = hp.xy - c1.xy;
      surfTangent = length(rad) > 1e-3 ? normalize(vec2(-rad.y, rad.x)) : vec2(1.0, 0.0);
    }
  }
  // Secondary cobalt-teal ceramic orb foreground right
  vec3 c2 = vec3(0.24, -0.17, 0.26);
  float r2 = 0.23;
  vec3 oc2 = ro - c2;
  float b2 = dot(oc2, rd), d2 = b2 * b2 - (dot(oc2, oc2) - r2 * r2);
  if (d2 > 0.0) {
    float t2 = -b2 - sqrt(d2);
    if (t2 > 0.0 && t2 < depth) {
      depth = t2;
      vec3 hp = ro + rd * t2;
      vec3 n = normalize(hp - c2);
      float ndl = max(dot(n, L), 0.0);
      float spec = pow(max(dot(reflect(-L, n), -rd), 0.0), 18.0);
      col = mix(vec3(0.008, 0.024, 0.075), vec3(0.035, 0.24, 0.36), smoothstep(0.02, 0.60, ndl));
      col = mix(col, vec3(0.42, 0.78, 0.72), smoothstep(0.60, 0.98, ndl)) + vec3(1.0, 0.94, 0.76) * spec * 0.72;
      vec2 rad = hp.xy - c2.xy;
      surfTangent = length(rad) > 1e-3 ? normalize(vec2(-rad.y, rad.x)) : vec2(1.0, 0.0);
    }
  }
}
vec2 boidFlowField(vec2 p, float t) {
  float a = sin(p.x * 5.2 + t * 0.62) * cos(p.y * 5.0 - t * 0.45);
  vec2 curl = vec2(-cos(p.y * 5.0 - t * 0.45) * sin(p.x * 5.2 + t * 0.62), sin(p.y * 5.0 - t * 0.45) * cos(p.x * 5.2 + t * 0.62));
  vec2 r1 = p - vec2(-0.06, 0.01);
  float d1 = length(r1);
  vec2 swirl = vec2(-r1.y, r1.x) / max(d1 + 0.12, 0.12);
  return normalize(curl * 0.90 + swirl * exp(-d1 * 1.45) * 1.55 + vec2(0.32, 0.18 * sin(a * 3.0)));
}
void evalBoidStroke(vec2 cellId, float grid, float t, bool flocking, out vec2 pos, out vec2 dir, out float seed) {
  vec2 h = hash22(cellId);
  seed = h.x;
  vec2 anchor = (cellId + 0.18 + 0.64 * h) / grid;
  vec3 tmpCol; vec2 surfT; float tmpD;
  sampleLitScene(anchor, tmpCol, surfT, tmpD);
  if (!flocking) {
    pos = anchor;
    dir = surfT;
    return;
  }
  vec2 vSelf = normalize(mix(surfT, boidFlowField(anchor, t), 0.72 * LIVELINESS));
  vec2 sep = vec2(0.0), ali = vec2(0.0), coh = vec2(0.0);
  float count = 0.0;
  for (int ny = -1; ny <= 1; ny++) {
    for (int nx = -1; nx <= 1; nx++) {
      if (nx == 0 && ny == 0) continue;
      vec2 nid = cellId + vec2(float(nx), float(ny));
      vec2 nh = hash22(nid);
      vec2 nAnchor = (nid + 0.18 + 0.64 * nh) / grid;
      vec2 nFlow = boidFlowField(nAnchor, t);
      vec2 nPos = nAnchor + nFlow * (0.48 * LIVELINESS / grid) * (0.65 + 0.35 * sin(t * 1.15 + nh.x * 6.283));
      vec2 diff = anchor - nPos;
      float dist = max(length(diff), 0.001);
      float rad = 1.70 / grid;
      if (dist < rad) {
        sep += (diff / (dist * dist)) * (0.30 / (grid * grid));
        ali += nFlow;
        coh += nPos;
        count += 1.0;
      }
    }
  }
  if (count > 0.0) {
    ali = normalize(ali / count);
    coh = (coh / count) - anchor;
  }
  vec2 steer = vSelf * (0.66 / grid) + sep * 0.44 + coh * (0.85 * FLOCK_COHESION);
  vec2 disp = steer * LIVELINESS * (0.72 + 0.28 * sin(t * 1.35 + h.y * 6.283));
  pos = anchor + disp;
  dir = normalize(mix(surfT, normalize(vSelf + ali * 0.90 + sep * grid * 0.38), clamp(LIVELINESS * 0.92, 0.0, 1.0)));
}
float brushSprite(vec2 local, vec2 halfSize, float seed, out float bristleHeight) {
  vec2 q = local / halfSize;
  q.y += 0.16 * (q.x * q.x - 0.35) * (seed - 0.5) * 2.0;
  float r = length(vec2(q.x * 0.95, q.y * 1.08));
  float bristles = 0.5 + 0.30 * sin(q.y * 18.0 + seed * 31.0) + 0.20 * sin(q.y * 34.0 - seed * 19.0);
  float endMask = smoothstep(1.06, 0.60, abs(q.x) + (1.0 - bristles) * 0.24);
  float sideMask = smoothstep(1.02, 0.68, abs(q.y) + (1.0 - bristles) * 0.12);
  float ovalMask = smoothstep(1.08, 0.70, r + (1.0 - bristles) * 0.16);
  float alpha = endMask * sideMask * ovalMask;
  float edgeBead = exp(-pow((abs(q.y) - 0.72) * 4.5, 2.0)) * 0.58;
  bristleHeight = (bristles * 0.65 + edgeBead) * alpha;
  return alpha;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  bool flocking = uv.x > 0.0;
  // Twin symmetric framing so both halves display the full sculptural still-life side by side
  vec2 p = vec2(flocking ? uv.x - 0.25 : uv.x + 0.25, uv.y) * 1.32;
  float weave = 0.94 + 0.06 * (sin(p.x * 240.0) * sin(p.y * 240.0));
  vec3 baseCol; vec2 baseT; float baseD;
  sampleLitScene(p, baseCol, baseT, baseD);
  vec3 col = mix(vec3(0.24, 0.19, 0.13) * weave, baseCol * 0.92, 0.80);
  for (int layer = 0; layer < 2; layer++) {
    float grid = layer == 0 ? STROKE_DENSITY * 0.65 : STROKE_DENSITY * 1.15;
    vec2 baseCell = floor(p * grid);
    float bestDepth = 1e9;
    vec3 bestPaint = col;
    float bestAlpha = 0.0;
    float bestRelief = 0.0;
    vec2 bestDir = vec2(1.0, 0.0);
    for (int j = -2; j <= 2; j++) {
      for (int i = -2; i <= 2; i++) {
        vec2 cid = baseCell + vec2(float(i), float(j)) + vec2(float(layer) * 13.7, float(layer) * 7.3);
        vec2 sPos, sDir; float seed;
        evalBoidStroke(cid, grid, iTime, flocking, sPos, sDir, seed);
        vec2 rel = p - sPos;
        vec2 perp = vec2(-sDir.y, sDir.x);
        vec2 local = vec2(dot(rel, sDir), dot(rel, perp));
        float lenScale = (layer == 0 ? 1.52 : 1.32) * (0.85 + 0.35 * seed) / grid;
        float widScale = (layer == 0 ? 0.54 : 0.42) * (0.88 + 0.25 * fract(seed * 7.1)) / grid;
        if (abs(local.x) > lenScale * 1.15 || abs(local.y) > widScale * 1.15) continue;
        float relief;
        float alpha = brushSprite(local, vec2(lenScale, widScale), seed, relief);
        if (alpha < 0.04) continue;
        vec3 sCol; vec2 st; float sDepth;
        sampleLitScene(sPos, sCol, st, sDepth);
        sCol *= vec3(0.90 + 0.20 * seed, 0.92 + 0.16 * fract(seed * 3.7), 0.90 + 0.20 * fract(seed * 5.3));
        float sortD = sDepth + seed * 0.08;
        if (sortD < bestDepth) {
          bestDepth = sortD;
          bestPaint = sCol;
          bestAlpha = alpha;
          bestRelief = relief;
          bestDir = sDir;
        }
      }
    }
    if (bestAlpha > 0.02) {
      float lightCatch = dot(normalize(vec2(-bestDir.y, bestDir.x)), normalize(vec2(0.65, 0.76)));
      float impasto = (bestRelief - 0.32) * (0.16 + 0.22 * lightCatch) * IMPASTO_RELIEF;
      vec3 painted = clamp(bestPaint + vec3(0.85, 0.78, 0.62) * impasto, 0.0, 1.35);
      col = mix(col, painted, clamp(bestAlpha * (layer == 0 ? 0.90 : 0.95), 0.0, 1.0));
    }
  }
  col = col / (1.0 + col * 0.35);
  if (abs(uv.x) < 0.003) col = vec3(0.95, 0.92, 0.86);
  fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}

Why they connect

Boids flocking takes particles and applies separation, alignment and cohesion, outputting updated particles. Here each particle starts as a surface sample from Painterly rendering for animation (Meier) and gets one more steering term: a spring back to its anchor on the mesh. Painterly rendering for animation (Meier) then consumes those particles, colours each from the lit render at its current position, and draws it as a depth-sorted brush sprite oriented along its velocity blended with the surface tangent. Transitions become possible too: release the tether and strokes migrate from one object to another.

How to build it

WebGPU compute in three.js. Scatter stroke particles over meshes in proportion to projected area and store their anchors in object space. Each frame, transform the anchors, run a grid-hashed boid step with the anchor spring weighted by a liveliness parameter, and write positions and velocities. Render instanced quads with a brush alpha, sorted by depth, or with order-independent blending for small strokes. Sample colour from a low-resolution lit pass. For scene transitions, reassign anchors to the next object's samples and let cohesion carry the strokes across.

Field marks

  1. High liveliness detaches strokes from surfaces until the form is unreadable.
  2. Depth sorting many sprites each frame costs overdraw and time.
  3. Strokes bunch at cohesion centres and leave bare canvas.
  4. Colour sampled at drifting positions smears across silhouettes.

Prior art

No prior art found on 2026-11-29.

Searches run (4)
  • arXiv: all:"painterly rendering" AND all:"flocking" → 0 results
  • GitHub repos: "painterly rendering" flocking → 0 results
  • arXiv: all:"brush strokes" AND all:"boids" → 0 results
  • GitHub repos: "brush strokes" boids → 0 results