2017-09-03 08:29:33 +00:00
|
|
|
#version 330 core
|
|
|
|
#ifdef GL_ES
|
|
|
|
#define LOWP lowp
|
|
|
|
precision mediump float;
|
|
|
|
#else
|
|
|
|
#define LOWP
|
|
|
|
#endif
|
|
|
|
|
|
|
|
varying LOWP vec4 vColor;
|
|
|
|
varying vec2 vTexCoord;
|
|
|
|
|
|
|
|
uniform int horizontal;
|
|
|
|
uniform sampler2D u_texture;
|
|
|
|
uniform float weight[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
|
|
|
|
|
|
|
|
void main() {
|
2017-10-09 00:07:34 +00:00
|
|
|
vec2 tex_offset = 1.0 / textureSize(u_texture, 0);
|
2017-10-10 01:04:42 +00:00
|
|
|
vec4 color = texture(u_texture, vTexCoord);
|
|
|
|
vec3 result = color.rgb * weight[0];
|
2017-10-09 00:07:34 +00:00
|
|
|
|
|
|
|
if (horizontal == 1) {
|
|
|
|
for (int i = 1; i < 5; ++i) {
|
|
|
|
result += texture(u_texture, vTexCoord + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
|
|
|
result += texture(u_texture, vTexCoord - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int i = 1; i < 5; ++i) {
|
|
|
|
result += texture(u_texture, vTexCoord + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
|
|
|
result += texture(u_texture, vTexCoord - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-10 01:04:42 +00:00
|
|
|
gl_FragColor = vec4(result, color.a);
|
2017-10-09 00:07:34 +00:00
|
|
|
}
|