{"version":3,"file":"TriangleBlurShader.cjs","sources":["../../src/shaders/TriangleBlurShader.ts"],"sourcesContent":["import { Vector2 } from 'three'\n\n/**\n * Triangle blur shader\n * based on glfx.js triangle blur shader\n * https://github.com/evanw/glfx.js\n *\n * A basic blur filter, which convolves the image with a\n * pyramid filter. The pyramid filter is separable and is applied as two\n * perpendicular triangle filters.\n */\n\nexport const TriangleBlurShader = {\n  uniforms: {\n    texture: { value: null },\n    delta: { value: new Vector2(1, 1) },\n  },\n\n  vertexShader: [\n    'varying vec2 vUv;',\n\n    'void main() {',\n\n    '\tvUv = uv;',\n    '\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',\n\n    '}',\n  ].join('\\n'),\n\n  fragmentShader: [\n    '#include <common>',\n\n    '#define ITERATIONS 10.0',\n\n    'uniform sampler2D texture;',\n    'uniform vec2 delta;',\n\n    'varying vec2 vUv;',\n\n    'void main() {',\n\n    '\tvec4 color = vec4( 0.0 );',\n\n    '\tfloat total = 0.0;',\n\n    // randomize the lookup values to hide the fixed number of samples\n\n    '\tfloat offset = rand( vUv );',\n\n    '\tfor ( float t = -ITERATIONS; t <= ITERATIONS; t ++ ) {',\n\n    '\t\tfloat percent = ( t + offset - 0.5 ) / ITERATIONS;',\n    '\t\tfloat weight = 1.0 - abs( percent );',\n\n    '\t\tcolor += texture2D( texture, vUv + delta * percent ) * weight;',\n    '\t\ttotal += weight;',\n\n    '\t}',\n\n    '\tgl_FragColor = color / total;',\n\n    '}',\n  ].join('\\n'),\n}\n"],"names":["Vector2"],"mappings":";;;AAYO,MAAM,qBAAqB;AAAA,EAChC,UAAU;AAAA,IACR,SAAS,EAAE,OAAO,KAAK;AAAA,IACvB,OAAO,EAAE,OAAO,IAAIA,MAAQ,QAAA,GAAG,CAAC,EAAE;AAAA,EACpC;AAAA,EAEA,cAAc;AAAA,IACZ;AAAA,IAEA;AAAA,IAEA;AAAA,IACA;AAAA,IAEA;AAAA,EAAA,EACA,KAAK,IAAI;AAAA,EAEX,gBAAgB;AAAA,IACd;AAAA,IAEA;AAAA,IAEA;AAAA,IACA;AAAA,IAEA;AAAA,IAEA;AAAA,IAEA;AAAA,IAEA;AAAA;AAAA,IAIA;AAAA,IAEA;AAAA,IAEA;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA,IAEA;AAAA,IAEA;AAAA,IAEA;AAAA,EAAA,EACA,KAAK,IAAI;AACb;;"}