#version 450 core #include "common.glsl" // Depth-aware upsample of the AO buffer; output is multiplied into the HDR // target by the blend unit (DST_COLOR, ZERO). in vec2 vUV; layout(binding = 0) uniform sampler2D uAo; layout(binding = 1) uniform sampler2D uDepth; uniform vec2 uAoTexel; layout(location = 0) out vec4 fragColor; void main() { float raw = texture(uDepth, vUV).r; if (raw >= 1.0) { fragColor = vec4(1.0); return; } float d0 = linearDepth(raw); float sum = 0.0, wsum = 0.0; for (int y = -1; y <= 1; ++y) for (int x = -1; x <= 1; ++x) { vec2 uv = vUV + vec2(x, y) * uAoTexel; float d = linearDepth(texture(uDepth, uv).r); float w = exp(-abs(d - d0) / (0.03 * d0 + 0.05)); sum += texture(uAo, uv).r * w; wsum += w; } fragColor = vec4(vec3(sum / max(wsum, 1e-4)), 1.0); }