From d2d22748b437861b211ef8422d1df5e5552165b4 Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Wed, 24 Apr 2024 13:03:55 +1000 Subject: [PATCH] Fix issue in shadow to opacity --- drivers/gles3/shaders/scene.glsl | 11 ++--------- .../forward_clustered/scene_forward_clustered.glsl | 12 ++---------- .../shaders/forward_mobile/scene_forward_mobile.glsl | 12 ++---------- 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index e1ddbe1d35c..797b9066a94 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -1859,23 +1859,16 @@ void main() { #endif // !MODE_RENDER_DEPTH #if defined(USE_SHADOW_TO_OPACITY) +#ifndef MODE_RENDER_DEPTH alpha = min(alpha, clamp(length(ambient_light), 0.0, 1.0)); #if defined(ALPHA_SCISSOR_USED) if (alpha < alpha_scissor) { discard; } -#else -#ifdef MODE_RENDER_DEPTH -#ifdef USE_OPAQUE_PREPASS - - if (alpha < opaque_prepass_threshold) { - discard; - } -#endif // USE_OPAQUE_PREPASS -#endif // MODE_RENDER_DEPTH #endif // !ALPHA_SCISSOR_USED +#endif // !MODE_RENDER_DEPTH #endif // USE_SHADOW_TO_OPACITY #ifdef MODE_RENDER_DEPTH diff --git a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl index 47d273d789d..cb07579c4b1 100644 --- a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl +++ b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl @@ -2235,24 +2235,16 @@ void fragment_shader(in SceneData scene_data) { } #ifdef USE_SHADOW_TO_OPACITY +#ifndef MODE_RENDER_DEPTH alpha = min(alpha, clamp(length(ambient_light), 0.0, 1.0)); #if defined(ALPHA_SCISSOR_USED) if (alpha < alpha_scissor) { discard; } -#else -#ifdef MODE_RENDER_DEPTH -#ifdef USE_OPAQUE_PREPASS - - if (alpha < scene_data.opaque_prepass_threshold) { - discard; - } - -#endif // USE_OPAQUE_PREPASS -#endif // MODE_RENDER_DEPTH #endif // ALPHA_SCISSOR_USED +#endif // !MODE_RENDER_DEPTH #endif // USE_SHADOW_TO_OPACITY #endif //!defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED) diff --git a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl index f0a51418568..b98ea5a27fa 100644 --- a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl +++ b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl @@ -1756,24 +1756,16 @@ void main() { } //spot lights #ifdef USE_SHADOW_TO_OPACITY +#ifndef MODE_RENDER_DEPTH alpha = min(alpha, clamp(length(ambient_light), 0.0, 1.0)); #if defined(ALPHA_SCISSOR_USED) if (alpha < alpha_scissor) { discard; } -#else -#ifdef MODE_RENDER_DEPTH -#ifdef USE_OPAQUE_PREPASS - - if (alpha < scene_data.opaque_prepass_threshold) { - discard; - } - -#endif // USE_OPAQUE_PREPASS -#endif // MODE_RENDER_DEPTH #endif // !ALPHA_SCISSOR_USED +#endif // !MODE_RENDER_DEPTH #endif // USE_SHADOW_TO_OPACITY #endif //!defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)