From ff35f6edbf7fec5ed0ad0129a7e4cfd609c716a6 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sat, 30 Nov 2024 00:13:54 +0100 Subject: [PATCH] Move to flag [ci skip] --- .../renderer_rd/effects/copy_effects.cpp | 8 ++++---- .../rendering/renderer_rd/effects/copy_effects.h | 1 + .../renderer_rd/shaders/effects/copy_to_fb.glsl | 16 ++++++++-------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/servers/rendering/renderer_rd/effects/copy_effects.cpp b/servers/rendering/renderer_rd/effects/copy_effects.cpp index 39293ac08c34..760c504cdb7c 100644 --- a/servers/rendering/renderer_rd/effects/copy_effects.cpp +++ b/servers/rendering/renderer_rd/effects/copy_effects.cpp @@ -587,6 +587,10 @@ void CopyEffects::copy_to_fb_rect(RID p_source_rd_texture, RID p_dest_framebuffe copy_to_fb.push_constant.flags |= COPY_TO_FB_FLAG_NORMAL; } + if (p_occlusion_culling_buffer) { + copy.push_constant.flags |= COPY_TO_FB_FLAG_OCCLUSION_CULLING_BUFFER; + } + if (p_src_rect != Rect2()) { copy_to_fb.push_constant.section[0] = p_src_rect.position.x; copy_to_fb.push_constant.section[1] = p_src_rect.position.y; @@ -605,10 +609,6 @@ void CopyEffects::copy_to_fb_rect(RID p_source_rd_texture, RID p_dest_framebuffe mode = p_secondary.is_valid() ? COPY_TO_FB_MULTIVIEW_WITH_DEPTH : COPY_TO_FB_MULTIVIEW; } else { mode = p_secondary.is_valid() ? COPY_TO_FB_COPY2 : COPY_TO_FB_COPY; - - if (p_occlusion_culling_buffer) { - mode = COPY_TO_FB_OCCLUSION_CULLING_BUFFER; - } } RID shader = copy_to_fb.shader.version_get_shader(copy_to_fb.shader_version, mode); diff --git a/servers/rendering/renderer_rd/effects/copy_effects.h b/servers/rendering/renderer_rd/effects/copy_effects.h index e810bcd5ef0b..e1469ffa7b1f 100644 --- a/servers/rendering/renderer_rd/effects/copy_effects.h +++ b/servers/rendering/renderer_rd/effects/copy_effects.h @@ -193,6 +193,7 @@ class CopyEffects { COPY_TO_FB_FLAG_LINEAR = (1 << 6), COPY_TO_FB_FLAG_NORMAL = (1 << 7), COPY_TO_FB_FLAG_USE_SRC_SECTION = (1 << 8), + COPY_TO_FB_FLAG_OCCLUSION_CULLING_BUFFER = (1 << 9), }; struct CopyToFbPushConstant { diff --git a/servers/rendering/renderer_rd/shaders/effects/copy_to_fb.glsl b/servers/rendering/renderer_rd/shaders/effects/copy_to_fb.glsl index 8b2c78a018b7..a3b707e3a2a4 100644 --- a/servers/rendering/renderer_rd/shaders/effects/copy_to_fb.glsl +++ b/servers/rendering/renderer_rd/shaders/effects/copy_to_fb.glsl @@ -84,6 +84,7 @@ void main() { #define FLAG_ALPHA_TO_ONE (1 << 5) #define FLAG_LINEAR (1 << 6) #define FLAG_NORMAL (1 << 7) +#define FLAG_OCCLUSION_CULLING_BUFFER (1 << 9) layout(push_constant, std430) uniform Params { vec4 section; @@ -202,14 +203,13 @@ void main() { if (bool(params.flags & FLAG_NORMAL)) { color.rgb = normalize(color.rgb * 2.0 - 1.0) * 0.5 + 0.5; } - -#ifdef MODE_OCCLUSION_CULLING_BUFFER - // Modify result to make the background partially visible, - // which helps with 3D navigation. - // This relies on the additive blend state from the `CopyEffects()` constructor. - color.a = (1.0 - color.r) * 0.5; - color.rgb = vec3(1.0, 0.0, 0.0); -#endif // MODE_OCCLUSION_CULLING_BUFFER + if (bool(params.flags & FLAG_OCCLUSION_CULLING_BUFFER)) { + // Modify result to make the background partially visible, + // which helps with 3D navigation. + // This relies on the additive blend state from the `CopyEffects()` constructor. + color.a = (1.0 - color.r) * 0.5; + color.rgb = vec3(1.0, 0.0, 0.0); + } frag_color = color / params.luminance_multiplier; #endif // MODE_SET_COLOR