diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ee905d1c..32c3a7b2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,9 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): ### Bug fixes * Fixed two block platform room portal traversal failing in some cases. +* Fixed dynamic light shadows not being handled correctly. ### New Features - * Added a particle based waterfall emitter object and associated sprite slots. - You must use this version: https://github.com/TombEngine/Resources/raw/refs/heads/main/Wad2%20Objects/Interactables/TEN_Waterfall_Emitter.wad2 diff --git a/TombEngine/Renderer/RendererFrame.cpp b/TombEngine/Renderer/RendererFrame.cpp index 53861d99a..f3333ad7b 100644 --- a/TombEngine/Renderer/RendererFrame.cpp +++ b/TombEngine/Renderer/RendererFrame.cpp @@ -589,6 +589,13 @@ namespace TEN::Renderer float attenuation = 1.0f - distance / light.Out; float intensity = attenuation * light.Intensity * light.Luma; + // If collecting shadows, try collecting shadow-casting light. + if (prioritizeShadowLight && light.CastShadows && intensity >= brightest) + { + brightest = intensity; + brightestLight = &light; + } + RendererLightNode node = { &light, intensity, distance, 1 }; tempLights.push_back(node); } @@ -635,13 +642,10 @@ namespace TEN::Renderer intensity = attenuation * light.Intensity * Luma(light.Color); // If collecting shadows, try collecting shadow-casting light. - if (light.CastShadows && prioritizeShadowLight && light.Type == LightType::Point) + if (prioritizeShadowLight && light.CastShadows && light.Type == LightType::Point && intensity >= brightest) { - if (intensity >= brightest) - { - brightest = intensity; - brightestLight = &light; - } + brightest = intensity; + brightestLight = &light; } } else if (light.Type == LightType::Spot) @@ -660,14 +664,11 @@ namespace TEN::Renderer float attenuation = 1.0f - dist / light.Out; intensity = attenuation * light.Intensity * light.Luma; - // If shadow pointer provided, try collecting shadow-casting light. - if (light.CastShadows && prioritizeShadowLight) + // If collecting shadows, try collecting shadow-casting light. + if (prioritizeShadowLight && light.CastShadows && intensity >= brightest) { - if (intensity >= brightest) - { - brightest = intensity; - brightestLight = &light; - } + brightest = intensity; + brightestLight = &light; } } else