From fad14d7e24d9cf587bcf3b710defc20cd99817d9 Mon Sep 17 00:00:00 2001 From: SaiyansKing <38609240+SaiyansKing@users.noreply.github.com> Date: Mon, 29 Nov 2021 14:53:55 +0100 Subject: [PATCH] Dynamic Shadows hotfix Enabled Dynamic Shadows can make lights disappear when Shadows are disabled --- D3D11Engine/D3D11GraphicsEngine.cpp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/D3D11Engine/D3D11GraphicsEngine.cpp b/D3D11Engine/D3D11GraphicsEngine.cpp index 267c2527..114fd5c0 100644 --- a/D3D11Engine/D3D11GraphicsEngine.cpp +++ b/D3D11Engine/D3D11GraphicsEngine.cpp @@ -4914,24 +4914,12 @@ void XM_CALLCONV D3D11GraphicsEngine::RenderShadowCube( Engine::GAPI->GetRendererState().BlendState.SetDirty(); } - // Dont render shadows from the sun when it isn't on the sky - if ( Engine::GAPI->GetRendererState().RendererSettings.DrawShadowGeometry && - Engine::GAPI->GetRendererState().RendererSettings.EnableShadows ) { - GetContext()->ClearDepthStencilView( face.Get(), D3D11_CLEAR_DEPTH, 1.0f, 0 ); + // Always render shadowcube when dynamic shadows are enabled + GetContext()->ClearDepthStencilView( face.Get(), D3D11_CLEAR_DEPTH, 1.0f, 0 ); - // Draw the world mesh without textures - DrawWorldAround( position, range, cullFront, indoor, noNPCs, renderedVobs, - renderedMobs, worldMeshCache ); - } else { - if ( Engine::GAPI->GetSky()->GetAtmoshpereSettings().LightDirection.y <= 0 ) { - GetContext()->ClearDepthStencilView( face.Get(), D3D11_CLEAR_DEPTH, 0.0f, - 0 ); // Always shadow in the night - } else { - GetContext()->ClearDepthStencilView( - face.Get(), D3D11_CLEAR_DEPTH, 1.0f, - 0 ); // Clear shadowmap when shadows not enabled - } - } + // Draw the world mesh without textures + DrawWorldAround( position, range, cullFront, indoor, noNPCs, renderedVobs, + renderedMobs, worldMeshCache ); // Restore state SetRenderingStage( oldStage );