Last active
August 23, 2021 07:38
-
-
Save infinnie/ab3709eaafcb999ccfdeb27101ef2345 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
precision highp float; | |
uniform vec3 origResolution; | |
uniform vec3 iResolution; | |
uniform sampler2D iChannel0; | |
uniform bool flip; | |
uniform vec2 direction; | |
vec4 blur9_1_0(sampler2D image, vec2 uv, vec2 resolution, vec2 direction, vec2 a) { | |
vec4 color = vec4(0.0); | |
vec2 off1 = (vec2(1.3846153846) * direction) / resolution; | |
vec2 off2 = (vec2(3.2307692308) * direction) / resolution; | |
if (direction.x == .0 && (uv * resolution).y < (resolution - a).y || direction.y == .0 && (uv * resolution).x > a.x) { | |
return texture2D(image, uv); | |
} | |
vec2 add1 = uv + off1; | |
vec2 sub1 = uv - off1; | |
vec2 add2 = uv + off2; | |
vec2 sub2 = uv - off2; | |
vec2 rpos = a / resolution; | |
bool horizontal = direction.y == .0; | |
color += texture2D(image, uv) * 0.2270270270; | |
color += texture2D(image, (horizontal ? add1.x >= rpos.x : add1.y >= 1.) ? uv : add1) * 0.3162162162; | |
color += texture2D(image, (horizontal ? sub1.x <= .0 : sub1.y <= (1. - rpos).y) ? uv : sub1) * 0.3162162162; | |
color += texture2D(image, (horizontal ? add2.x >= rpos.x : add2.y >= 1.) ? uv : add2) * 0.0702702703; | |
color += texture2D(image, (horizontal ? sub2.x <= .0 : sub2.y <= (1. - rpos).y) ? uv : sub2) * 0.0702702703; | |
return color; | |
} | |
void main() { | |
vec2 uv = vec2(gl_FragCoord.xy / iResolution.xy); | |
if (flip) { | |
uv.y = 1.0 - uv.y; | |
} | |
gl_FragColor = blur9_1_0(iChannel0, uv, iResolution.xy, direction, origResolution.xy); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment