diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp index 069b43203f2..ce0b4a9f9c4 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -2028,6 +2028,16 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co } } + if (using_separate_specular && is_environment(p_render_data->environment) && (environment_get_background(p_render_data->environment) == RS::ENV_BG_CANVAS)) { + // Canvas background mode does not clear the color buffer, but copies over it. If screen-space specular effects are enabled and the background is blank, + // this results in ghosting due to the separate specular buffer copy. Need to explicitly clear the specular buffer once we're done with it to fix it. + RENDER_TIMESTAMP("Clear Separate Specular (Canvas Background Mode)"); + Vector blank_clear_color; + blank_clear_color.push_back(Color(0.0, 0.0, 0.0)); + RD::get_singleton()->draw_list_begin(rb_data->get_specular_only_fb(), RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD, blank_clear_color); + RD::get_singleton()->draw_list_end(); + } + if (scene_state.used_screen_texture) { RENDER_TIMESTAMP("Copy Screen Texture");