Skip to content

Commit

Permalink
Move to flag [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Calinou committed Nov 29, 2024
1 parent ba257ab commit ff35f6e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
8 changes: 4 additions & 4 deletions servers/rendering/renderer_rd/effects/copy_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions servers/rendering/renderer_rd/effects/copy_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions servers/rendering/renderer_rd/shaders/effects/copy_to_fb.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ff35f6e

Please sign in to comment.