blur shader works

This commit is contained in:
minjaesong
2017-07-04 23:30:48 +09:00
parent 3e64d8447c
commit c29f663a0e
2 changed files with 117 additions and 49 deletions

View File

@@ -1,12 +1,31 @@
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
uniform vec3 iResolution;
uniform float flip;
uniform vec2 direction;
vec4 blur(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
vec4 color = vec4(0.0);
vec2 off1 = vec2(1.3846153846) * direction;
vec2 off2 = vec2(3.2307692308) * direction;
color += texture2D(image, uv) * 0.2270270270;
color += texture2D(image, uv + (off1 / resolution)) * 0.3162162162;
color += texture2D(image, uv - (off1 / resolution)) * 0.3162162162;
color += texture2D(image, uv + (off2 / resolution)) * 0.0702702703;
color += texture2D(image, uv - (off2 / resolution)) * 0.0702702703;
return color;
}
void main() {
//gl_FragColor = v_color * texture2D(u_texture, v_texCoords);
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
vec2 uv = vec2(gl_FragCoord.xy / iResolution.xy);
if (flip == 1.0) {
uv.y = 1.0 - uv.y;
}
gl_FragColor = blur(u_texture, uv, iResolution.xy, direction);
}