From c9632d0eb6082f1b00de380274a30de061e8a438 Mon Sep 17 00:00:00 2001 From: Florent Guiocheau Date: Sat, 28 Dec 2024 11:36:28 +0100 Subject: [PATCH] Fix regression with shadows when light range is 0 or close --- servers/rendering/renderer_scene_cull.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index a9941141f87..0b98fc6769e 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -2510,7 +2510,7 @@ bool RendererSceneCull::_light_instance_update_shadow(Instance *p_instance, cons } real_t radius = RSG::light_storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_RANGE); - real_t z_near = 0.005f; + real_t z_near = MIN(0.005f, radius); Projection cm; cm.set_perspective(90, 1, z_near, radius); @@ -2600,7 +2600,7 @@ bool RendererSceneCull::_light_instance_update_shadow(Instance *p_instance, cons real_t radius = RSG::light_storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_RANGE); real_t angle = RSG::light_storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_SPOT_ANGLE); - real_t z_near = 0.005f; + real_t z_near = MIN(0.005f, radius); Projection cm; cm.set_perspective(angle * 2.0, 1.0, z_near, radius);