summaryrefslogtreecommitdiff
path: root/advanced_lighting/9.ssao/blur.frag
blob: dea23e8d2c68ed1ebc1d4fc6691b653792c287c9 (plain)
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

in vert_t {
	vec2 tex_coords;
} vert;

out float frag_color;

uniform sampler2D ssao;

void main()
{
	vec2 texel_size = 1.0 / vec2(textureSize(ssao, 0));
	float result = 0.0;
	for (int x = -2; x < 2; x++) {
		for (int y = -2; y < 2; y++) {
			vec2 offset = vec2(float(x), float(y)) * texel_size;
			result += texture(ssao, vert.tex_coords + offset).r;
		}
	}
	frag_color = result / (4.0 * 4.0);
}