Anisotropic Kuwahara filter
Kuwahara filtering with elliptical, direction-aligned sectors driven by a structure tensor, producing smooth painterly strokes that follow image features instead of axis-aligned blocks.
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 | |
| Unity | None found | |
| Unreal 5.7 | None found | No built-in anisotropic Kuwahara painterly filter; requires a custom post-process material. |
| Blender 5.2 | Built in | Compositor > Add > Creative > Kuwahara > Variation = Anisotropic docs |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
First, a structure tensor is estimated per pixel from Sobel gradients and smoothed with a Gaussian. Its eigenvectors give the local feature orientation and its eigenvalues give anisotropy. Each pixel then samples an ellipse oriented along that direction, divided into eight sectors weighted by a smooth polynomial or Gaussian rather than a hard window. For each sector it computes a weighted mean and variance, and blends the sector means with weights that favour low-variance sectors, instead of a hard winner-take-all choice. The soft weighting removes the discontinuities of the classic filter, and the oriented ellipses make edges follow brush-like curves. A multi-scale extension further preserves large-scale structure.
When to choose it
Reach for it when
- want an oil painting look from a rendered frame
- blocky artifacts in painterly image filter
- stylize a scene so strokes follow edges and shapes
- photo abstraction that keeps edges crisp but smooths regions
Choose it when you want convincing oil-paint or watercolour-like abstraction from a rendered frame and can budget two or three passes. Prefer Kuwahara filter for the cheapest option. Prefer Painterly rendering with curved brush strokes when you need visible individual brush strokes with direction and texture rather than a smooth filter.
Field marks
- Flickers on animated scenes because the structure tensor changes frame to frame
- Over-smoothing removes small details and faces unless strength is limited
- Orientation is unstable in flat regions, causing swirls
- Expensive at large radius without separable approximation or mip-based tricks
Presets
Left: noisy source. Right: anisotropic Kuwahara, 8 elliptical sectors oriented by the structure tensor
{
"RAD": 10,
"QEXP": 4,
"ALPHA": 1
}Show GLSL (46 lines)
float hash(vec2 c){uvec2 u=uvec2(ivec2(floor(c)));uint h=u.x*1597334673u^u.y*3812015801u;h^=h>>15;h*=2246822519u;h^=h>>13;h*=3266489917u;h^=h>>16;return float(h)*(1./4294967296.);}
float lum(vec3 c){return dot(c,vec3(.2126,.7152,.0722));}
vec3 gam(vec3 c){return pow(clamp(c,0.,1.),vec3(1./2.2));}
vec3 img(vec2 p){
vec3 c=mix(vec3(.12,.18,.34),vec3(.95,.72,.45),clamp(p.y+.5,0.,1.));
vec2 q=p-vec2(-.03,.14); float rr=.16; float d=length(q)-rr;
vec3 n=normalize(vec3(q/rr,sqrt(max(1.-dot(q,q)/(rr*rr),0.))));
float l=clamp(dot(n,normalize(vec3(-.5,.6,.6))),0.,1.);
c=mix(c,vec3(.85,.26,.2)*(.18+.9*l),smoothstep(.002,-.002,d));
vec2 r=p-vec2(0.,-.2);
if(abs(r.x)<.2&&abs(r.y)<.09) c=mix(vec3(.1,.35,.3),vec3(.93,.92,.85),smoothstep(-.3,.3,sin(r.x*340.+r.y*90.)));
if(p.y<-.34&&p.y>-.42){ vec3 h=.5+.5*cos(6.2832*((p.x+.25)*2.+vec3(0.,.33,.67))); c=h; }
c=mix(c,vec3(.97,.85,.2),smoothstep(.003,-.003,abs(p.x-.17)-.025)*step(.0,p.y)*step(p.y,.4));
return c;
}
const float RAD=10.0; // P
const float QEXP=4.0; // P
const float ALPHA=1.0; // P
vec3 src(vec2 p){return img(p)+(hash(floor(p*512.))-.5)*.16;}
void mainImage(out vec4 fragColor,in vec2 fragCoord){
vec2 uv=(fragCoord-.5*iResolution.xy)/iResolution.y;bool R=uv.x>0.;vec2 q=vec2(uv.x+(R?-.25:.25),uv.y);
vec3 col;
if(!R) col=src(q);
else{
float px=1./512.,E=0.,F=0.,G=0.;
for(int j=-1;j<=1;j++)for(int i=-1;i<=1;i++){vec2 o=q+vec2(float(i),float(j))*4.*px;
float gx=lum(img(o+vec2(2.*px,0.)))-lum(img(o-vec2(2.*px,0.))),gy=lum(img(o+vec2(0.,2.*px)))-lum(img(o-vec2(0.,2.*px)));
E+=gx*gx;F+=gx*gy;G+=gy*gy;}
float th=.5*atan(2.*F,E-G),r=sqrt((E-G)*(E-G)+4.*F*F),A=r/(E+G+1e-6);
vec2 g=vec2(cos(th),sin(th)),f=vec2(-g.y,g.x);
float a=RAD*(ALPHA+A)/ALPHA,b=RAD*ALPHA/(ALPHA+A);
vec3 m[8],s[8];float w[8];
for(int k=0;k<8;k++){m[k]=vec3(0.);s[k]=vec3(0.);w[k]=0.;}
for(int j=-4;j<=4;j++)for(int i=-4;i<=4;i++){
vec2 u=vec2(float(i),float(j))/4.;float l2=dot(u,u);if(l2>1.)continue;
vec3 c=src(q+(u.x*a*f+u.y*b*g)*px);float wt=exp(-2.5*l2);
int k=int(clamp(floor((atan(u.y,u.x)/6.2831853+.5)*8.),0.,7.));
m[k]+=c*wt;s[k]+=c*c*wt;w[k]+=wt;}
vec3 acc=vec3(0.);float ws=0.;
for(int k=0;k<8;k++){if(w[k]<1e-4)continue;vec3 mu=m[k]/w[k];vec3 v=max(s[k]/w[k]-mu*mu,0.);
float wk=1./(1.+pow(20.*sqrt(v.x+v.y+v.z),QEXP));acc+=mu*wk;ws+=wk;}
col=acc/ws;
}
if(abs(uv.x)<.0015)col=vec3(1.);fragColor=vec4(clamp(col,0.,1.),1.);
}Attribution: written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| anisotropic-kuwahara-specimen | Tesla T4 1920x1080 | 171× baseline (extreme) · 5.63 ms / 5.80 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| anisotropic-kuwahara-specimen | NVIDIA L4 1920x1080 | 113× baseline (extreme) · 1.80 ms / 1.82 ms · 3.1× faster on L4 | opengl-timer-query · Cross-architecture validation |
| anisotropic-kuwahara-specimen | NVIDIA A100-SXM4-40GB 1920x1080 | 56.1× baseline (heavy) · 1.62 ms / 1.63 ms · 3.5× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Stroke-based rendering, Painterly rendering with curved brush strokes, Mipmapping and anisotropic texture filtering.
Crosses
- Depth/normal Sobel edge outlines: Painterly colour regions from the filter, lines from depth/normal 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
- primaryJan Eric Kyprianidis (2011). Image and video abstraction by multi-scale anisotropic Kuwahara filtering. Proceedings of the ACM SIGGRAPH/Eurographics Symposium on Non-Photorealistic Animation and Rendering.Verified via crossref · 2026-11-29doi:10.1145/2024676.2024686
- implementationGarrettGunnell (2022). GarrettGunnell/Post-Processing. My Unity post processing pipeline and shadersGitHub API · license MIT · 2026-11-29