{
 "id": "jump-flood-outline",
 "title": "Jump-flood wide outlines",
 "aliases": [],
 "domain": "npr",
 "subdomain": "outlines",
 "stage": "post",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "unity",
  "unreal"
 ],
 "year_introduced": 2006,
 "inputs": [
  "ldr-image",
  "depth"
 ],
 "outputs": [
  "ldr-image",
  "texture"
 ],
 "style": "stylized",
 "dynamic": "dynamic",
 "summary": "Builds a per-pixel nearest-seed field with the jump flooding algorithm, so outlines of any pixel width cost a fixed log-many passes instead of an ever-growing blur kernel.",
 "how_it_works": "Render the objects to outline into a mask, seeding each covered pixel with its own coordinate. Then run log2(N) full-screen passes with step sizes N/2, N/4, … 1; in each pass a pixel looks at the 9 neighbours at that offset and keeps whichever stored seed is closest to it. The result approximates a Voronoi diagram, giving every pixel the coordinate of its nearest mask pixel. A final pass draws the outline where the distance to that seed is below the desired width, which makes lines resolution-independent in thickness and perfectly round, including inner glow or gradient falloff. Ben Golus's write-up adapts this for Unity with anti-aliased sub-pixel distance.",
 "when_to_use": "Choose it for very wide, uniform outlines, selection highlights and glows around arbitrary shapes. Prefer `inverted-hull-outline` for cheap thin character outlines on a few meshes, and `screen-space-edge-outline` for creases and interior lines, which flood fill cannot produce.",
 "cost": {
  "class": "medium",
  "notes": "About log2(width) cheap full-screen passes plus mask render; outline width barely changes cost."
 },
 "failure_modes": [
  "Approximate: occasional wrong nearest seeds produce small seams or speckles that need an extra 1+JFA pass",
  "Needs extra ping-pong buffers with 16-bit or float precision for large screens",
  "Outline ignores occlusion by default; lines can draw through walls unless depth-aware",
  "Overlapping mask objects share seeds, so adjacent objects cannot have different line colours without an ID channel"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/1111411.1111431",
   "type": "paper",
   "title": "Jump flooding in GPU with applications to Voronoi diagram and distance transform",
   "authors": [
    "Guodong Rong",
    "Tiow-Seng Tan"
   ],
   "year": 2006,
   "venue": "Proceedings of the 2006 symposium on Interactive 3D graphics and games  - SI3D '06",
   "url": "https://doi.org/10.1145/1111411.1111431",
   "ids": {
    "doi": "10.1145/1111411.1111431"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111431",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111431",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111431",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111431",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111431",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "rong2006jump"
  },
  {
   "role": "tutorial",
   "key": "url:https://bgolus.medium.com/the-quest-for-very-wide-outlines-ba82ed442cd9",
   "type": "tutorial",
   "title": "The Quest for Very Wide Outlines",
   "authors": [
    "Ben Golus"
   ],
   "year": null,
   "venue": "bgolus.medium.com",
   "url": "https://bgolus.medium.com/the-quest-for-very-wide-outlines-ba82ed442cd9",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 403,
    "live": false,
    "archive": {
     "url": "http://web.archive.org/web/20261029222309/https://bgolus.medium.com/the-quest-for-very-wide-outlines-ba82ed442cd9",
     "timestamp": "20261029222309"
    },
    "page_title": "Just a moment...",
    "host": "bgolus.medium.com",
    "title_confirmed_by_page": false,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "wayback",
     "endpoint": "https://archive.org/wayback/available?url=https://bgolus.medium.com/the-quest-for-very-wide-outlines-ba82ed442cd9",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "wayback",
     "endpoint": "https://archive.org/wayback/available?url=https://bgolus.medium.com/the-quest-for-very-wide-outlines-ba82ed442cd9",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 0,
   "__bib": "golusquest"
  },
  {
   "role": "implementation",
   "key": "gh:charlesgrs/jumpfloodoutline",
   "type": "code",
   "title": "CharlesGrs/JumpFloodOutline",
   "description": "JumpFloodOutline",
   "authors": [
    "CharlesGrs"
   ],
   "year": 2022,
   "venue": "GitHub",
   "url": "https://github.com/CharlesGrs/JumpFloodOutline",
   "ids": {
    "repo": "CharlesGrs/JumpFloodOutline"
   },
   "license": "Unlicense",
   "extra": {
    "stars": 0,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2022-06-29T12:53:01Z",
    "language": "ShaderLab",
    "homepage": null,
    "license_name": "The Unlicense"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/CharlesGrs/JumpFloodOutline",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/CharlesGrs/JumpFloodOutline",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/CharlesGrs/JumpFloodOutline",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/CharlesGrs/JumpFloodOutline",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/CharlesGrs/JumpFloodOutline",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/CharlesGrs/JumpFloodOutline",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "charlesgrs2022charlesgrs"
  }
 ],
 "presets": [
  {
   "id": "jump-flood-outline-live",
   "title": "Jump-flood outline — exact Euclidean distance field wide outlines & JFA iso-rings",
   "runtime": "glsl-fragment",
   "params": {
    "P_OUTLINE_WIDTH": 0.048,
    "P_HALO_SPREAD": 0.16,
    "P_BAND_VIS": 0.75,
    "P_SPEED": 1
   },
   "basis": "original",
   "license_note": "Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).",
   "code": "const float P_OUTLINE_WIDTH = 0.048; // P Outline Width [0.008, 0.14, 0.004]\nconst float P_HALO_SPREAD = 0.16; // P Glow Halo [0.02, 0.35, 0.01]\nconst float P_BAND_VIS = 0.75; // P EDT Iso-Bands [0.0, 1.5, 0.05]\nconst float P_SPEED = 1.0; // P Motion Speed [0.0, 2.5, 0.05]\n\nmat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }\n\nfloat sdRoundedBox(vec2 p, vec2 b, float r) {\n  vec2 q = abs(p) - b + r;\n  return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r;\n}\n\nfloat sdStar5(vec2 p, float r, float rf) {\n  vec2 k1 = vec2(0.80901699, -0.58778525);\n  vec2 k2 = vec2(-k1.x, k1.y);\n  p.x = abs(p.x);\n  p -= 2.0 * max(dot(k1, p), 0.0) * k1;\n  p -= 2.0 * max(dot(k2, p), 0.0) * k2;\n  p.x = abs(p.x);\n  p.y -= r;\n  vec2 ba = rf * vec2(-k1.y, k1.x) - vec2(0.0, 1.0);\n  float h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);\n  return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);\n}\n\n// Multi-part complex selection silhouette (illustrates JFA miter-free wide outlines)\nvec2 mapSelection(vec2 p, float t) {\n  // Primary rotating 5-point star emblem\n  vec2 p1 = rot2(t * 0.55) * (p - vec2(-0.14, 0.04));\n  float d1 = sdStar5(p1, 0.18, 0.48);\n\n  // Orbiting rounded mechanical capsule\n  vec2 c2 = vec2(0.24 + 0.04 * cos(t * 1.1), -0.08 + 0.07 * sin(t * 0.9));\n  vec2 p2 = rot2(-t * 0.7) * (p - c2);\n  float d2 = sdRoundedBox(p2, vec2(0.11, 0.055), 0.025);\n\n  // Floating satellite ring\n  vec2 c3 = vec2(0.16 * cos(t * 0.8 + 1.2), 0.26 + 0.03 * sin(t * 1.4));\n  float d3 = abs(length(p - c3) - 0.068) - 0.018;\n\n  float d = min(d1, min(d2, d3));\n  float id = (d == d1) ? 1.0 : ((d == d2) ? 2.0 : 3.0);\n  return vec2(d, id);\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 px = 1.0 / iResolution.y;\n  float t = iTime * max(P_SPEED, 0.0);\n\n  float width = clamp(P_OUTLINE_WIDTH, 0.006, 0.18);\n  float halo = clamp(P_HALO_SPREAD, 0.02, 0.42);\n  float bandVis = clamp(P_BAND_VIS, 0.0, 1.6);\n\n  vec2 res = mapSelection(uv, t);\n  float d = res.x;\n\n  // Approximate nearest seed direction (what JFA stores in each pixel's RG seed-coordinate buffer!)\n  vec2 e = vec2(0.002, 0.0);\n  vec2 grad = normalize(vec2(\n    mapSelection(uv + e.xy, t).x - mapSelection(uv - e.xy, t).x,\n    mapSelection(uv + e.yx, t).x - mapSelection(uv - e.yx, t).x\n  ) + 1e-5);\n  float seedAng = atan(grad.y, grad.x);\n\n  // Dark drafting-grid viewport background\n  vec3 bg = mix(vec3(0.03, 0.04, 0.065), vec3(0.06, 0.08, 0.125), smoothstep(-0.55, 0.55, uv.y));\n  vec2 g = abs(fract(uv * 12.0 - 0.5) - 0.5) / (12.0 * px);\n  bg += vec3(0.035, 0.055, 0.085) * smoothstep(1.3, 0.0, min(g.x, g.y)) * 0.45;\n\n  // Visualize JFA Euclidean distance field iso-contours radiating outward in powers-of-two jump bands\n  float distPos = max(d, 0.0);\n  float iso = smoothstep(0.08, 0.015, abs(fract(distPos * 26.0 - iTime * 0.45) - 0.5));\n  float jfaBand = exp(-distPos * 4.5);\n  vec3 seedTint = 0.5 + 0.5 * cos(seedAng + vec3(0.0, 2.094, 4.188));\n  vec3 col = bg + mix(vec3(0.14, 0.42, 0.72), seedTint, 0.35) * iso * jfaBand * 0.42 * bandVis;\n\n  // Smooth exponential selection glow halo outside the wide outline\n  float glow = exp(-max(d - width * 0.5, 0.0) / halo);\n  col += vec3(0.16, 0.78, 1.15) * glow * 0.48;\n\n  // Crisp constant-width JFA wide outline band (rounded exterior joins, zero corner artifacts)\n  float outerAA = smoothstep(width + 1.5 * px, width - 1.5 * px, d);\n  float innerAA = smoothstep(1.5 * px, -1.5 * px, d);\n  float outlineMask = clamp(outerAA - innerAA, 0.0, 1.0);\n\n  // Animated marching-ants dash accents along the outer rim of the wide outline\n  float rimLine = smoothstep(2.5 * px, 0.0, abs(d - width));\n  vec3 outlineCol = mix(vec3(1.05, 0.68, 0.16), vec3(0.22, 0.94, 1.08), clamp(d / max(width, 0.005), 0.0, 1.0));\n  col = mix(col, outlineCol * 1.18, outlineMask);\n  col += vec3(1.35, 1.25, 0.95) * rimLine * 0.7;\n\n  // Interior shaded 2.5D metallic badge fill\n  if (innerAA > 0.001) {\n    float bevel = clamp(-d * 14.0, 0.0, 1.0);\n    vec3 nFake = normalize(vec3(grad * (1.0 - bevel) * 0.7, 0.75 + 0.25 * bevel));\n    vec3 lDir = normalize(vec3(0.55, 0.75, 0.6));\n    float diff = max(dot(nFake, lDir), 0.0);\n    float spec = pow(max(dot(nFake, normalize(lDir + vec3(0.0, 0.0, 1.0))), 0.0), 28.0);\n    vec3 fillBase = (res.y < 1.5) ? vec3(0.24, 0.30, 0.42) : ((res.y < 2.5) ? vec3(0.32, 0.26, 0.38) : vec3(0.22, 0.36, 0.40));\n    vec3 fillCol = fillBase * (0.35 + 0.95 * diff) + vec3(0.85, 0.92, 1.0) * spec * 0.65;\n    col = mix(col, fillCol, innerAA);\n  }\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "jump-flood-outline",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T16:50:13.852Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.5853,
      "std": 0.164,
      "unique_colors": 416
     },
     "image": "/specimens/jump-flood-outline-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "screen-space-edge-outline",
  "inverted-hull-outline"
 ],
 "extends": [
  "screen-space-edge-outline"
 ],
 "supersedes": [],
 "combines_with": [
  {
   "id": "toon-shading",
   "why": "Toon-shaded characters get a thick uniform selection or hero outline from the flooded distance field."
  }
 ],
 "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/jump-flood-outline.json"
 },
 "solves": [
  "thick outlines cost too much with blur kernels",
  "need wide uniform selection highlight around shapes",
  "outline width must scale without extra cost",
  "glow around arbitrary silhouettes at fixed passes"
 ],
 "authority": "Rong & Tan, 2006",
 "url": "https://texelatlas.vercel.app/t/jump-flood-outline/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 9.05,
  "tier": "moderate",
  "p50_ms": 0.2978,
  "p95_ms": 0.3127,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "jump-flood-outline-live",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 7.5,
   "tier": "moderate",
   "p50_ms": 0.1192,
   "p95_ms": 0.1194,
   "speedup_x": 2.5,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 5.75,
   "tier": "light",
   "p50_ms": 0.1656,
   "p95_ms": 0.1658,
   "speedup_x": 1.8,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}