24 lines
649 B
GLSL
24 lines
649 B
GLSL
#version 330 core
|
|
out vec4 FragColor;
|
|
|
|
in vec2 TexCoords;
|
|
|
|
uniform sampler2D image;
|
|
uniform int horizontal;
|
|
|
|
const float weights[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
|
|
|
|
void main()
|
|
{
|
|
vec2 texel = 1.0 / vec2(textureSize(image, 0));
|
|
vec2 direction = horizontal != 0 ? vec2(texel.x, 0.0) : vec2(0.0, texel.y);
|
|
|
|
vec3 color = texture(image, TexCoords).rgb * weights[0];
|
|
for (int i = 1; i < 5; i++) {
|
|
color += texture(image, TexCoords + direction * float(i)).rgb * weights[i];
|
|
color += texture(image, TexCoords - direction * float(i)).rgb * weights[i];
|
|
}
|
|
|
|
FragColor = vec4(color, 1.0);
|
|
}
|