From 57ba7ded879b77a0617784ba969a8bcb6615467b Mon Sep 17 00:00:00 2001 From: clayjohn Date: Mon, 30 Oct 2023 22:38:57 +0100 Subject: [PATCH] Fix bug with alpha to coverage by enabling depth discard when using alpha to coverage --- .../shaders/forward_clustered/scene_forward_clustered.glsl | 6 ++---- .../shaders/forward_mobile/scene_forward_mobile.glsl | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) 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 8e6db7583ea..206c2fb2452 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 @@ -1019,13 +1019,11 @@ void fragment_shader(in SceneData scene_data) { #endif // ALPHA_ANTIALIASING_EDGE_USED #ifdef MODE_RENDER_DEPTH -#ifdef USE_OPAQUE_PREPASS -#ifndef ALPHA_SCISSOR_USED +#if defined(USE_OPAQUE_PREPASS) || defined(ALPHA_ANTIALIASING_EDGE_USED) if (alpha < scene_data.opaque_prepass_threshold) { discard; } -#endif // !ALPHA_SCISSOR_USED -#endif // USE_OPAQUE_PREPASS +#endif // USE_OPAQUE_PREPASS || ALPHA_ANTIALIASING_EDGE_USED #endif // MODE_RENDER_DEPTH #endif // !USE_SHADOW_TO_OPACITY 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 a9e9a617d65..5ed36697030 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 @@ -854,13 +854,11 @@ void main() { #endif // ALPHA_ANTIALIASING_EDGE_USED #ifdef MODE_RENDER_DEPTH -#ifdef USE_OPAQUE_PREPASS -#ifndef ALPHA_SCISSOR_USED +#if defined(USE_OPAQUE_PREPASS) || defined(ALPHA_ANTIALIASING_EDGE_USED) if (alpha < scene_data.opaque_prepass_threshold) { discard; } -#endif // !ALPHA_SCISSOR_USED -#endif // USE_OPAQUE_PREPASS +#endif // USE_OPAQUE_PREPASS || ALPHA_ANTIALIASING_EDGE_USED #endif // MODE_RENDER_DEPTH #endif // !USE_SHADOW_TO_OPACITY