23 lines
724 B
GLSL
23 lines
724 B
GLSL
#version 450 core
|
|
#include "common.glsl"
|
|
// Separable depth-aware blur of the half-res AO buffer.
|
|
|
|
in vec2 vUV;
|
|
layout(binding = 0) uniform sampler2D uAo;
|
|
layout(binding = 1) uniform sampler2D uDepth;
|
|
uniform vec2 uDir; // texel step along the blur axis
|
|
layout(location = 0) out vec4 fragColor;
|
|
|
|
void main() {
|
|
float d0 = linearDepth(texture(uDepth, vUV).r);
|
|
float sum = 0.0, wsum = 0.0;
|
|
for (int i = -4; i <= 4; ++i) {
|
|
vec2 uv = vUV + uDir * float(i);
|
|
float d = linearDepth(texture(uDepth, uv).r);
|
|
float w = exp(-float(i * i) / 12.0) * exp(-abs(d - d0) / (0.03 * d0 + 0.05));
|
|
sum += texture(uAo, uv).r * w;
|
|
wsum += w;
|
|
}
|
|
fragColor = vec4(sum / max(wsum, 1e-4));
|
|
}
|