Skip to content

shader

shader(o): ShaderFilter

A custom fragment shader as a filter: WebGL only. On Canvas 2D it is skipped (the node is drawn without it, engine.stats.filtersSkipped counts it, the console says so once): check engine.supports.shaders and pick another look there. Compiled once per distinct source. With a WebGL engine running, a shader that does not compile throws here with the compiler’s log; otherwise the error is logged once at its first use and the filter skipped.

ShaderOptions

ShaderFilter

const wave = shader({
fragment: `uniform float uAmp;
void main() { gl_FragColor = texture2D(uTexture, vUv + vec2(sin(vUv.y * 40.0 + uTime * 4.0) * uAmp, 0.0)); }`,
uniforms: { uAmp: 0.004 },
padding: 8,
})
flag.filters = [wave]