Kuwahara

A painterly filter that smooths flat areas into brush-like strokes while keeping edges sharp. It is an anisotropic generalized Kuwahara filter: the sampling area follows the local edge direction.

Based on Maxime Heckel's article on painterly shaders.

import { Kuwahara } from '@react-three/postprocessing'
import { BlendFunction } from 'postprocessing'

return (
  <Kuwahara
    radius={4} // filter radius in pixels
    sectorCount={8} // number of sectors, 2 to 8
    blendFunction={BlendFunction.NORMAL} // blend mode
  />
)

The filter takes about radius * sectorCount * 3 texture samples per pixel, so large radii get expensive quickly. Lower sectorCount when raising radius.

Props

NameTypeDefaultDescription
radiusNumber4The filter radius in pixels.
sectorCountNumber8The number of sectors, 2 to 8. Fewer is cheaper but blockier.
blendFunctionBlendFunctionBlendFunction.NORMALThe blend function of this effect.
opacityNumber1The opacity of this effect.