From b0b2975efc15ec474c669a7e4923959d6984ea42 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sat, 19 Dec 2020 22:36:58 +0300 Subject: [PATCH] Use shadow blurring in deferred rendering --- libs/gfx/source/renderer/deferred.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/gfx/source/renderer/deferred.cpp b/libs/gfx/source/renderer/deferred.cpp index 87dc18eb..5183568b 100644 --- a/libs/gfx/source/renderer/deferred.cpp +++ b/libs/gfx/source/renderer/deferred.cpp @@ -455,7 +455,17 @@ void main() // color = vec3(float(l & 1), float(l & 2) / 2.0, float(l & 4) / 4.0); // break; - color *= texture(u_shadow, vec4(tc.x, tc.y, float(cascade), tc.z)); + float s = 0.0; + for (int tx = -2; tx <= 2; ++tx) + { + for (int ty = -2; ty <= 2; ++ty) + { + float d = 1.0 / 1024.0 / pow(2.0, float(cascade)); + s += texture(u_shadow, vec4(tc.x + float(tx) * d, tc.y + float(ty) * d, float(cascade), tc.z)) / 25.0; + } + } + + color *= s; break; } }