2024-02-04 22:00:38 +01:00
|
|
|
#version 330 core
|
|
|
|
out vec4 FragColor;
|
|
|
|
|
|
|
|
in vec2 TexCoords;
|
|
|
|
|
|
|
|
uniform sampler2D image;
|
|
|
|
|
2024-02-07 18:51:40 +01:00
|
|
|
uniform int count;
|
2024-02-04 22:00:38 +01:00
|
|
|
uniform bool horizontal;
|
|
|
|
uniform float weight[5] = float[] (0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162);
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec2 tex_offset = 1.0 / textureSize(image, 0); // gets size of single texel
|
|
|
|
vec3 result = texture(image, TexCoords).rgb * weight[0];
|
|
|
|
if(horizontal)
|
|
|
|
{
|
2024-02-07 18:51:40 +01:00
|
|
|
for(int i = 1; i < count; ++i)
|
2024-02-04 22:00:38 +01:00
|
|
|
{
|
|
|
|
result += texture(image, TexCoords + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
|
|
|
result += texture(image, TexCoords - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(int i = 1; i < 5; ++i)
|
|
|
|
{
|
|
|
|
result += texture(image, TexCoords + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
|
|
|
result += texture(image, TexCoords - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FragColor = vec4(result, 1.0);
|
|
|
|
}
|