#version 450 core #include "common.glsl" // Depth-aware upsample of the half-res volumetric buffer, applied to the scene. in vec2 vUV; layout(binding = 0) uniform sampler2D uColor; layout(binding = 1) uniform sampler2D uDepth; layout(binding = 2) uniform sampler2D uVolume; uniform vec2 uVolumeTexel; uniform int uEnabled; layout(location = 0) out vec4 fragColor; void main() { vec3 c = texture(uColor, vUV).rgb; if (uEnabled == 0) { fragColor = vec4(c, 1.0); return; } float d0 = linearDepth(texture(uDepth, vUV).r); vec4 acc = vec4(0.0); float wsum = 0.0; for (int y = -1; y <= 1; ++y) for (int x = -1; x <= 1; ++x) { vec2 uv = vUV + vec2(x, y) * uVolumeTexel; float ds = linearDepth(texture(uDepth, uv).r); float w = exp(-abs(ds - d0) / (0.04 * d0 + 0.05)) * (x == 0 && y == 0 ? 2.0 : 1.0); acc += texture(uVolume, uv) * w; wsum += w; } vec4 v = acc / max(wsum, 1e-4); fragColor = vec4(c * v.a + v.rgb, 1.0); }