summaryrefslogtreecommitdiffstats
path: root/cwd/assets/altcraft/shaders/frag/blur.fs
blob: b49032f73c6d2644bfd5b74378262da0f46459cb (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, 3);
}