Fixed dynamic light shadows not being handled correctly

This commit is contained in:
Lwmte 2025-01-19 05:41:05 +01:00
parent db2649e936
commit 7be096f86a
2 changed files with 15 additions and 14 deletions

View file

@ -7,9 +7,9 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
### Bug fixes ### Bug fixes
* Fixed two block platform room portal traversal failing in some cases. * Fixed two block platform room portal traversal failing in some cases.
* Fixed dynamic light shadows not being handled correctly.
### New Features ### New Features
* Added a particle based waterfall emitter object and associated sprite slots. * 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 - You must use this version: https://github.com/TombEngine/Resources/raw/refs/heads/main/Wad2%20Objects/Interactables/TEN_Waterfall_Emitter.wad2

View file

@ -589,6 +589,13 @@ namespace TEN::Renderer
float attenuation = 1.0f - distance / light.Out; float attenuation = 1.0f - distance / light.Out;
float intensity = attenuation * light.Intensity * light.Luma; 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 }; RendererLightNode node = { &light, intensity, distance, 1 };
tempLights.push_back(node); tempLights.push_back(node);
} }
@ -635,13 +642,10 @@ namespace TEN::Renderer
intensity = attenuation * light.Intensity * Luma(light.Color); intensity = attenuation * light.Intensity * Luma(light.Color);
// If collecting shadows, try collecting shadow-casting light. // 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) else if (light.Type == LightType::Spot)
@ -660,14 +664,11 @@ namespace TEN::Renderer
float attenuation = 1.0f - dist / light.Out; float attenuation = 1.0f - dist / light.Out;
intensity = attenuation * light.Intensity * light.Luma; intensity = attenuation * light.Intensity * light.Luma;
// If shadow pointer provided, try collecting shadow-casting light. // If collecting shadows, try collecting shadow-casting light.
if (light.CastShadows && prioritizeShadowLight) if (prioritizeShadowLight && light.CastShadows && intensity >= brightest)
{ {
if (intensity >= brightest) brightest = intensity;
{ brightestLight = &light;
brightest = intensity;
brightestLight = &light;
}
} }
} }
else else