Kuwahara filter
Edge-preserving smoothing that splits each pixel's neighbourhood into four overlapping sub-windows and outputs the mean of the one with the lowest variance, giving a flat, oil-paint look.
In the family Stylized & non-photorealistic rendering, painterly image filters
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 Kuwahara painterly post-process filter. |
| Unity | None found | |
| Unreal 5.7 | None found | No built-in Kuwahara post-process filter; requires a custom post-process material. |
| Blender 5.2 | Built in | Compositor > Add > Creative > Kuwahara docs |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
For every pixel, the square neighbourhood is divided into four quadrants that all share the centre pixel. For each quadrant, compute the mean colour and the variance of brightness. The output is the mean of the quadrant with the smallest variance. Flat regions get averaged strongly, while pixels on a boundary choose the quadrant lying entirely on one side, so edges are not blurred. The larger the radius, the more paint-like the result. Because every pixel computes four windows, cost grows with radius squared, and implementations often use summed-area tables, separable approximations or reduced taps to stay real-time. The blocky look from fixed square windows is the motivation for the anisotropic variant.
When to choose it
Reach for it when
- want an oil painting look on a render
- photo should look like a flat poster-style painting
- smooth colour regions but keep edges sharp
- cheap painterly look as a post-process
- reduce detail without blurring edges
Choose it for quick oil-painting or poster-like post-processing of any frame, including 3D renders. Prefer Anisotropic Kuwahara filter when blocky square artefacts are visible and you can afford a structure tensor pass. Prefer Posterization for a colour-count reduction without spatial smoothing.
Field marks
- Square window produces visible blocky, boxy shapes at larger radii
- Noisy flat regions can flip between quadrants and create speckle
- Can wash out thin lines and small high-contrast details
- Colour banding and temporal shimmer when the winning quadrant switches between frames
Presets
Classic Kuwahara, radius 5, procedural image
{
"radius": 5
}Show GLSL (36 lines)
// GLSL ES 3.0, Shadertoy-style: classic 4-quadrant Kuwahara on a procedural image
const int R = 5; // quadrant radius in pixels
const float SPLIT = 0.5; // left half shows the filtered result, right half the source (set 0.0 for all filtered)
vec3 img(vec2 p){
vec2 q = p / iResolution.y;
float n = sin(q.x*17.0)*sin(q.y*13.0) + 0.5*sin(q.x*41.0 + q.y*29.0);
float d = length(q - vec2(0.9, 0.5));
vec3 c = 0.5 + 0.5*cos(6.2831*(vec3(0.0,0.33,0.67) + n*0.25 + d*1.4));
c += 0.18*sin(q.x*400.0)*sin(q.y*380.0); // high-frequency grain to be removed
return c;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord){
if(fragCoord.x / iResolution.x > SPLIT){ fragColor = vec4(clamp(img(fragCoord),0.0,1.0),1.0); return; }
vec3 bestMean = vec3(0.0);
float bestVar = 1e9;
for(int k=0;k<4;k++){
vec2 s = vec2((k & 1) == 0 ? 1.0 : -1.0, (k & 2) == 0 ? 1.0 : -1.0);
vec3 sum = vec3(0.0); float sum2 = 0.0;
for(int j=0;j<=R;j++){
for(int i=0;i<=R;i++){
vec3 c = img(fragCoord + vec2(float(i), float(j))*s);
sum += c;
float l = dot(c, vec3(0.299,0.587,0.114));
sum2 += l*l;
}
}
float N = float((R+1)*(R+1));
vec3 m = sum / N;
float ml = dot(m, vec3(0.299,0.587,0.114));
float v = sum2/N - ml*ml;
if(v < bestVar){ bestVar = v; bestMean = m; }
}
fragColor = vec4(clamp(bestMean, 0.0, 1.0), 1.0);
}
Attribution: written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| kuwahara-procedural-r5 | Tesla T4 1920x1080 | 54.2× baseline (heavy) · 1.78 ms / 1.92 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| kuwahara-procedural-r5 | NVIDIA L4 1920x1080 | 46.3× baseline (heavy) · 0.736 ms / 0.739 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| kuwahara-procedural-r5 | NVIDIA A100-SXM4-40GB 1920x1080 | 36.2× baseline (heavy) · 1.04 ms / 1.05 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Stroke-based rendering.
Crosses
- Anisotropic Kuwahara filter: Classic filter is the baseline; the anisotropic one replaces its square windows.
- Depth/normal Sobel edge outlines: Painterly colour from Kuwahara plus crisp edge lines from G-buffer edges.
Sources
- primaryJan Eric Kyprianidis, Henry Kang, Jürgen Döllner (2009). Image and Video Abstraction by Anisotropic Kuwahara Filtering. Computer Graphics Forum.Verified via crossref · 2026-11-29doi:10.1111/j.1467-8659.2009.01574.x
- implementationGarrettGunnell (2022). GarrettGunnell/Post-Processing. My Unity post processing pipeline and shadersGitHub API · license MIT · 2026-11-29
- implementationnoxtgm (2023). noxtgm/kuwahara-filter. Kuwahara filter for Unreal Engine's post process component.GitHub API · license CC0-1.0 · 2026-11-29