Kuwahara smoothing — oil paint that keeps its edges.
GLSL fragment shader
The effect's own code. The uniforms and helpers above it — uTex, uFeedback, the depth proxy, the frame ring, depthAt(), timeAt() — are the same header every Ether-MOSH shader opens with, and are documented once on the registry rather than reprinted on all 143 pages.
void main(){ vec2 px = uRadius / uResolution; vec4 srcTex = texture2D(uTex, vUv); vec3 c = srcTex.rgb; // Four overlapping quadrants; the flattest one wins. That is what keeps // edges crisp while flat areas go smooth — a blur would soften both. vec3 bestMean = c; float bestVar = 1e6; for (int q = 0; q < 4; q++) { vec2 dir = vec2((q == 0 || q == 3) ? 1.0 : -1.0, (q < 2) ? 1.0 : -1.0); // 2x2 per quadrant, not 3x3: 16 fetches instead of 36. At 36 this was // 19x a passthrough — more than the whole stack's frame budget on its own, // which would have made it unreachable by the director. vec3 sum = vec3(0.0), sum2 = vec3(0.0); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { vec3 t = texture2D(uTex, vUv + dir * vec2(float(i), float(j)) * px * 2.4).rgb; sum += t; sum2 += t * t; } } vec3 mean = sum / 4.0; vec3 varv = max(vec3(0.0), sum2 / 4.0 - mean * mean); float v = varv.r + varv.g + varv.b; if (v < bestVar) { bestVar = v; bestMean = mean; } } gl_FragColor = vec4(mix(c, bestMean, uAmount), srcTex.a); }