From dfc05caf06fb9a2b6167be7f822aa86f4283ae7e Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 13 Dec 2024 16:20:16 +0100 Subject: [PATCH] Use lower shadow normal bias for distant directional shadow splits This reduces the visual discrepancy between shadow splits when Normal Bias is greater than 0. Shadow acne at a distance may be slightly more present, but if the bias and normal bias values are tuned to avoid acne up close, acne will usually not be present in distant splits. --- servers/rendering/renderer_rd/storage_rd/light_storage.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp index 83a3c11714..124f1ebe5a 100644 --- a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp @@ -714,7 +714,9 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged light_data.shadow_split_offsets[j] = split; float bias_scale = light_instance->shadow_transform[j].bias_scale * light_data.soft_shadow_scale; light_data.shadow_bias[j] = light->param[RS::LIGHT_PARAM_SHADOW_BIAS] / 100.0 * bias_scale; - light_data.shadow_normal_bias[j] = light->param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] * light_instance->shadow_transform[j].shadow_texel_size; + // Use lower shadow normal bias for distant splits, relative to the share taken by the split. + // This helps reduce peter-panning at a distance. + light_data.shadow_normal_bias[j] = light->param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] * light_instance->shadow_transform[j].shadow_texel_size * light_data.shadow_split_offsets[0] / split; light_data.shadow_transmittance_bias[j] = light->param[RS::LIGHT_PARAM_TRANSMITTANCE_BIAS] / 100.0 * bias_scale; light_data.shadow_z_range[j] = light_instance->shadow_transform[j].farplane; light_data.shadow_range_begin[j] = light_instance->shadow_transform[j].range_begin;