/** * @filter Triangle Blur * @description This is the most basic blur filter, which convolves the image with a * pyramid filter. The pyramid filter is separable and is applied as two * perpendicular triangle filters. */ export type TriangleBlurProps = { /** The radius of the pyramid convolved with the image. */ radius?: number; /** @deprecated internal property */ delta?: [number, number]; }; export type TriangleBlurUniforms = TriangleBlurProps; /** * @filter Triangle Blur * @description This is the most basic blur filter, which convolves the image with a * pyramid filter. The pyramid filter is separable and is applied as two * perpendicular triangle filters. */ export declare const triangleBlur: { readonly name: "triangleBlur"; readonly dependencies: [{ readonly name: "random"; readonly source: "fn random(scale: vec3f, seed: f32) -> f32 {\n return fract(sin(dot(scale + vec3f(seed), vec3f(12.9898, 78.233, 151.7182))) * 43758.5453 + seed);\n}\n"; readonly fs: "float random(vec3 scale, float seed) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n"; }]; readonly source: "struct triangleBlurUniforms {\n radius: f32,\n delta: vec2f,\n};\n\n@group(0) @binding(auto) var triangleBlur: triangleBlurUniforms;\n\nfn triangleBlur_sampleColor(\n sourceTexture: texture_2d,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;\n\n var color = vec4f(0.0);\n var total = 0.0;\n\n /* randomize the lookup values to hide the fixed number of samples */\n let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);\n\n for (var t = -30.0; t <= 30.0; t += 1.0) {\n let percent = (t + offset - 0.5) / 30.0;\n let weight = 1.0 - abs(percent);\n let offsetColor = textureSample(\n sourceTexture,\n sourceTextureSampler,\n texCoord + adjustedDelta * percent\n );\n\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n let premultipliedOffsetColor = vec4f(offsetColor.rgb * vec3f(offsetColor.a), offsetColor.a);\n\n color += premultipliedOffsetColor * weight;\n total += weight;\n }\n\n color /= total;\n\n /* switch back from pre-multiplied alpha */\n let unpremultipliedRgb = color.rgb / vec3f(color.a + 0.00001);\n\n return vec4f(unpremultipliedRgb, color.a);\n}\n"; readonly fs: "layout(std140) uniform triangleBlurUniforms {\n float radius;\n vec2 delta;\n} triangleBlur;\n\nvec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;\n\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 offsetColor = texture(source, texCoord + adjustedDelta * percent);\n\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n offsetColor.rgb *= offsetColor.a;\n\n color += offsetColor * weight;\n total += weight;\n }\n\n color = color / total;\n\n /* switch back from pre-multiplied alpha */\n color.rgb /= color.a + 0.00001;\n\n return color;\n}\n"; readonly props: TriangleBlurProps; readonly uniforms: TriangleBlurUniforms; readonly uniformTypes: { readonly radius: "f32"; readonly delta: "vec2"; }; readonly propTypes: { readonly radius: { readonly value: 20; readonly min: 0; readonly softMax: 100; }; readonly delta: { readonly value: readonly [1, 0]; readonly private: true; }; }; readonly passes: [{ readonly sampler: true; readonly uniforms: { readonly delta: [1, 0]; }; }, { readonly sampler: true; readonly uniforms: { readonly delta: [0, 1]; }; }]; }; //# sourceMappingURL=triangleblur.d.ts.map