Jump-flood wide outlines
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.
In the family Stylized & non-photorealistic rendering, outlines
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | No built-in jump-flood wide outline post-process. |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
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 choose it
Reach for it when
- 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
Choose it for very wide, uniform outlines, selection highlights and glows around arbitrary shapes. Prefer Inverted-hull outlines for cheap thin character outlines on a few meshes, and Depth/normal Sobel edge outlines for creases and interior lines, which flood fill cannot produce.
Field marks
- 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
Presets
Jump-flood outline — exact Euclidean distance field wide outlines & JFA iso-rings
{
"P_OUTLINE_WIDTH": 0.048,
"P_HALO_SPREAD": 0.16,
"P_BAND_VIS": 0.75,
"P_SPEED": 1
}Show GLSL (111 lines)
const float P_OUTLINE_WIDTH = 0.048; // P Outline Width [0.008, 0.14, 0.004]
const float P_HALO_SPREAD = 0.16; // P Glow Halo [0.02, 0.35, 0.01]
const float P_BAND_VIS = 0.75; // P EDT Iso-Bands [0.0, 1.5, 0.05]
const float P_SPEED = 1.0; // P Motion Speed [0.0, 2.5, 0.05]
mat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }
float sdRoundedBox(vec2 p, vec2 b, float r) {
vec2 q = abs(p) - b + r;
return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r;
}
float sdStar5(vec2 p, float r, float rf) {
vec2 k1 = vec2(0.80901699, -0.58778525);
vec2 k2 = vec2(-k1.x, k1.y);
p.x = abs(p.x);
p -= 2.0 * max(dot(k1, p), 0.0) * k1;
p -= 2.0 * max(dot(k2, p), 0.0) * k2;
p.x = abs(p.x);
p.y -= r;
vec2 ba = rf * vec2(-k1.y, k1.x) - vec2(0.0, 1.0);
float h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);
return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);
}
// Multi-part complex selection silhouette (illustrates JFA miter-free wide outlines)
vec2 mapSelection(vec2 p, float t) {
// Primary rotating 5-point star emblem
vec2 p1 = rot2(t * 0.55) * (p - vec2(-0.14, 0.04));
float d1 = sdStar5(p1, 0.18, 0.48);
// Orbiting rounded mechanical capsule
vec2 c2 = vec2(0.24 + 0.04 * cos(t * 1.1), -0.08 + 0.07 * sin(t * 0.9));
vec2 p2 = rot2(-t * 0.7) * (p - c2);
float d2 = sdRoundedBox(p2, vec2(0.11, 0.055), 0.025);
// Floating satellite ring
vec2 c3 = vec2(0.16 * cos(t * 0.8 + 1.2), 0.26 + 0.03 * sin(t * 1.4));
float d3 = abs(length(p - c3) - 0.068) - 0.018;
float d = min(d1, min(d2, d3));
float id = (d == d1) ? 1.0 : ((d == d2) ? 2.0 : 3.0);
return vec2(d, id);
}
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 px = 1.0 / iResolution.y;
float t = iTime * max(P_SPEED, 0.0);
float width = clamp(P_OUTLINE_WIDTH, 0.006, 0.18);
float halo = clamp(P_HALO_SPREAD, 0.02, 0.42);
float bandVis = clamp(P_BAND_VIS, 0.0, 1.6);
vec2 res = mapSelection(uv, t);
float d = res.x;
// Approximate nearest seed direction (what JFA stores in each pixel's RG seed-coordinate buffer!)
vec2 e = vec2(0.002, 0.0);
vec2 grad = normalize(vec2(
mapSelection(uv + e.xy, t).x - mapSelection(uv - e.xy, t).x,
mapSelection(uv + e.yx, t).x - mapSelection(uv - e.yx, t).x
) + 1e-5);
float seedAng = atan(grad.y, grad.x);
// Dark drafting-grid viewport background
vec3 bg = mix(vec3(0.03, 0.04, 0.065), vec3(0.06, 0.08, 0.125), smoothstep(-0.55, 0.55, uv.y));
vec2 g = abs(fract(uv * 12.0 - 0.5) - 0.5) / (12.0 * px);
bg += vec3(0.035, 0.055, 0.085) * smoothstep(1.3, 0.0, min(g.x, g.y)) * 0.45;
// Visualize JFA Euclidean distance field iso-contours radiating outward in powers-of-two jump bands
float distPos = max(d, 0.0);
float iso = smoothstep(0.08, 0.015, abs(fract(distPos * 26.0 - iTime * 0.45) - 0.5));
float jfaBand = exp(-distPos * 4.5);
vec3 seedTint = 0.5 + 0.5 * cos(seedAng + vec3(0.0, 2.094, 4.188));
vec3 col = bg + mix(vec3(0.14, 0.42, 0.72), seedTint, 0.35) * iso * jfaBand * 0.42 * bandVis;
// Smooth exponential selection glow halo outside the wide outline
float glow = exp(-max(d - width * 0.5, 0.0) / halo);
col += vec3(0.16, 0.78, 1.15) * glow * 0.48;
// Crisp constant-width JFA wide outline band (rounded exterior joins, zero corner artifacts)
float outerAA = smoothstep(width + 1.5 * px, width - 1.5 * px, d);
float innerAA = smoothstep(1.5 * px, -1.5 * px, d);
float outlineMask = clamp(outerAA - innerAA, 0.0, 1.0);
// Animated marching-ants dash accents along the outer rim of the wide outline
float rimLine = smoothstep(2.5 * px, 0.0, abs(d - width));
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));
col = mix(col, outlineCol * 1.18, outlineMask);
col += vec3(1.35, 1.25, 0.95) * rimLine * 0.7;
// Interior shaded 2.5D metallic badge fill
if (innerAA > 0.001) {
float bevel = clamp(-d * 14.0, 0.0, 1.0);
vec3 nFake = normalize(vec3(grad * (1.0 - bevel) * 0.7, 0.75 + 0.25 * bevel));
vec3 lDir = normalize(vec3(0.55, 0.75, 0.6));
float diff = max(dot(nFake, lDir), 0.0);
float spec = pow(max(dot(nFake, normalize(lDir + vec3(0.0, 0.0, 1.0))), 0.0), 28.0);
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));
vec3 fillCol = fillBase * (0.35 + 0.95 * diff) + vec3(0.85, 0.92, 1.0) * spec * 0.65;
col = mix(col, fillCol, innerAA);
}
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| jump-flood-outline-live | Tesla T4 1920x1080 | 9.05× baseline (moderate) · 0.298 ms / 0.313 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| jump-flood-outline-live | NVIDIA L4 1920x1080 | 7.50× baseline (moderate) · 0.119 ms / 0.119 ms · 2.5× faster on L4 | opengl-timer-query · Cross-architecture validation |
| jump-flood-outline-live | NVIDIA A100-SXM4-40GB 1920x1080 | 5.75× baseline (light) · 0.166 ms / 0.166 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Toon / cel shading with lighting ramps: Toon-shaded characters get a thick uniform selection or hero outline from the flooded distance field.
Sources
- primaryGuodong Rong, Tiow-Seng Tan (2006). Jump flooding in GPU with applications to Voronoi diagram and distance transform. Proceedings of the 2006 symposium on Interactive 3D graphics and games - SI3D '06.Verified via crossref · 2026-11-29doi:10.1145/1111411.1111431
- tutorialBen Golus. The Quest for Very Wide Outlines. bgolus.medium.com.Archived copy (live page blocked or gone) · 2026-11-29
- implementationCharlesGrs (2022). CharlesGrs/JumpFloodOutline. JumpFloodOutlineGitHub API · license Unlicense · 2026-11-29