glsl-util/gaussianBlur.glsl
2017-01-30 15:48:18 +09:00

16 lines
841 B
GLSL

vec4 gaussianBlur(sampler2D texture, vec2 uv, float radius, vec2 resolution, vec2 direction) {
vec4 color = vec4(0.0);
vec2 step = radius / resolution * direction;
color += texture2D(texture, uv - 4.0 * step) * 0.02699548325659403;
color += texture2D(texture, uv - 3.0 * step) * 0.06475879783294587;
color += texture2D(texture, uv - 2.0 * step) * 0.12098536225957168;
color += texture2D(texture, uv - 1.0 * step) * 0.17603266338214976;
color += texture2D(texture, uv) * 0.19947114020071635;
color += texture2D(texture, uv + 1.0 * step) * 0.17603266338214976;
color += texture2D(texture, uv + 2.0 * step) * 0.12098536225957168;
color += texture2D(texture, uv + 3.0 * step) * 0.06475879783294587;
color += texture2D(texture, uv + 4.0 * step) * 0.02699548325659403;
return color;
}
#pragma glslify: export(gaussianBlur)