Files
polypartiCL/shaders/blur2.fs
T
2026-07-13 21:03:43 -07:00

32 lines
814 B
GLSL

#version 330
in vec2 fragTexCoord;
in vec4 fragColor;
uniform sampler2D texture0;
uniform vec4 colDiffuse;
uniform vec2 resolution;
uniform vec2 direction; // (1,0) for horizontal pass, (0,1) for vertical pass
out vec4 finalColor;
void main()
{
vec2 texel = direction / resolution;
// 9-tap Gaussian, weights from Pascal's-triangle-style approximation
const float weight[5] = float[](
0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216
);
vec4 color = texture(texture0, fragTexCoord) * weight[0];
for (int i = 1; i < 5; i++) {
vec2 offset = texel * float(i);
color += texture(texture0, fragTexCoord + offset) * weight[i];
color += texture(texture0, fragTexCoord - offset) * weight[i];
}
finalColor = color * colDiffuse * fragColor * 1.8;
}