summaryrefslogtreecommitdiffstats
path: root/cwd/assets/altcraft/shaders/frag/blur.fs
blob: 89d4498bdaa03e5bb849783f5c7318c9394decd7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#version 330 core

out vec4 fragColor;

in vec2 uv;

uniform sampler2D blurInput;
uniform int blurScale;

void main() {
    vec2 texelSize = 1.0f / vec2(textureSize(blurInput, 0));
    vec4 result = vec4(0.0f);
    for (int x = -blurScale; x < blurScale; x++) 
    {
        for (int y = -blurScale; y < blurScale; y++) 
        {
            vec2 offset = vec2(float(x), float(y)) * texelSize;
            result += texture(blurInput, uv + offset);
        }
    }
    fragColor = result / pow(blurScale * 2.0f, 2);
}