Untitled
Loading...
Searching...
No Matches
ssao_blur.frag
Go to the documentation of this file.
1#version 330 core
2out float FragColor;
4
5uniform sampler2D uSSAOInput;
6uniform sampler2D uDepth;
7
8void main() {
9 vec2 texelSize = 1.0 / vec2(textureSize(uSSAOInput, 0));
10
11
12 float result = 0.0;
13 float weightSum = 0.0;
14
15 float centerDepth = texture(uDepth, vUV).r;
16
17 for (int x = -2; x <= 2; ++x) {
18 for (int y = -2; y <= 2; ++y) {
19
20 vec2 offset = vec2(float(x), float(y)) * texelSize;
21 vec2 sampleUV = vUV + offset;
22
23 float sampleAO = texture(uSSAOInput, sampleUV).r;
24 float sampleDepth = texture(uDepth, sampleUV).r;
25
26 float depthDiff = abs(centerDepth - sampleDepth);
27
28 float weight = exp(-depthDiff * 1000.0);
29
30 result += sampleAO * weight;
31 weightSum += weight;
32 }
33 }
34
35 FragColor = result / weightSum;
36
37}
void main()
uniform sampler2D uDepth
in vec2 vUV
Definition lightmap.frag:13
uniform sampler2D uSSAOInput
Definition ssao_blur.frag:5
out float FragColor
Definition ssao_blur.frag:2
Definition types.h:11