added bloom shader
This commit is contained in:
33
android/assets/shaders/gaussian_blur.fsh
Executable file
33
android/assets/shaders/gaussian_blur.fsh
Executable file
@@ -0,0 +1,33 @@
|
||||
#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() {
|
||||
vec2 tex_offset = 1.0 /textureSize(u_texture, 0);
|
||||
vec3 result = texture(u_texture, vTexCoord).rgb * weight[0];
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(result, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user