From 182d6d86020cb8880ae7597daa638c7f7378d2d9 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 23 May 2024 21:51:57 +0200 Subject: [PATCH] Fix regression in missing shadows inside Global Surface Atals --- Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp | 4 +++- Source/Shaders/GI/GlobalSurfaceAtlas.shader | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp index f48bd627e..858825145 100644 --- a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp +++ b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp @@ -946,8 +946,8 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co // Draw light PROFILE_GPU_CPU_NAMED("Directional Light"); const bool useShadow = light.CanRenderShadow(renderContext.View); - // TODO: test perf/quality when using Shadow Map for directional light (ShadowsPass::Instance()->LastDirLightShadowMap) instead of Global SDF trace light.SetShaderData(data.Light, useShadow); + data.Light.ShadowsBufferAddress = useShadow; // Use this to indicate if trace shadow (SDF trace) data.Light.Color *= light.IndirectLightingIntensity; data.LightShadowsStrength = 1.0f - light.ShadowsStrength; context->UpdateCB(_cb0, &data); @@ -981,6 +981,7 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co PROFILE_GPU_CPU_NAMED("Point Light"); const bool useShadow = light.CanRenderShadow(renderContext.View); light.SetShaderData(data.Light, useShadow); + data.Light.ShadowsBufferAddress = useShadow; // Use this to indicate if trace shadow (SDF trace) data.Light.Color *= light.IndirectLightingIntensity; data.LightShadowsStrength = 1.0f - light.ShadowsStrength; context->UpdateCB(_cb0, &data); @@ -1014,6 +1015,7 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co PROFILE_GPU_CPU_NAMED("Spot Light"); const bool useShadow = light.CanRenderShadow(renderContext.View); light.SetShaderData(data.Light, useShadow); + data.Light.ShadowsBufferAddress = useShadow; // Use this to indicate if trace shadow (SDF trace) data.Light.Color *= light.IndirectLightingIntensity; data.LightShadowsStrength = 1.0f - light.ShadowsStrength; context->UpdateCB(_cb0, &data); diff --git a/Source/Shaders/GI/GlobalSurfaceAtlas.shader b/Source/Shaders/GI/GlobalSurfaceAtlas.shader index 1af8880bc..23ebddda8 100644 --- a/Source/Shaders/GI/GlobalSurfaceAtlas.shader +++ b/Source/Shaders/GI/GlobalSurfaceAtlas.shader @@ -167,9 +167,6 @@ float4 PS_Lighting(AtlasVertexOutput input) : SV_Target BRANCH if (NoL > 0) { - // TODO: try using shadow map for on-screen pixels - // TODO: try using cone trace with Global SDF for smoother shadow (eg. for sun shadows or for area lights) - // Shot a ray from texel into the light to see if there is any occluder GlobalSDFTrace trace; trace.Init(gBuffer.WorldPos + gBuffer.Normal * shadowBias, L, bias, toLightDst - bias);