diff options
author | clayjohn <claynjohn@gmail.com> | 2023-01-03 15:46:03 -0800 |
---|---|---|
committer | clayjohn <claynjohn@gmail.com> | 2023-01-03 15:46:03 -0800 |
commit | 72bc7e5a9d3b5013d8fc97c5060aeb53e56c2e3e (patch) | |
tree | cf9619eede72adf7a7b7b0a13450f5d7184df7ef /servers/rendering/renderer_viewport.cpp | |
parent | 26bed8aa85fc2f98e38552a82929e1deb5b29d8a (diff) | |
download | redot-engine-72bc7e5a9d3b5013d8fc97c5060aeb53e56c2e3e.tar.gz |
Always try to clear render target before drawing 3D with Canvas BG mode
This is necessary to ensure that we aren't copying garbage data to the 3D renderbuffer
Diffstat (limited to 'servers/rendering/renderer_viewport.cpp')
-rw-r--r-- | servers/rendering/renderer_viewport.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 8cec531393..dd3650d8ab 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -496,6 +496,9 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { } if (scenario_draw_canvas_bg && canvas_map.begin() && canvas_map.begin()->key.get_layer() > scenario_canvas_max_layer) { + // There may be an outstanding clear request if a clear was requested, but no 2D elements were drawn. + // Clear now otherwise we copy over garbage from the render target. + RSG::texture_storage->render_target_do_clear_request(p_viewport->render_target); if (!can_draw_3d) { RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas); } else { @@ -536,6 +539,9 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { } if (scenario_draw_canvas_bg && E.key.get_layer() >= scenario_canvas_max_layer) { + // There may be an outstanding clear request if a clear was requested, but no 2D elements were drawn. + // Clear now otherwise we copy over garbage from the render target. + RSG::texture_storage->render_target_do_clear_request(p_viewport->render_target); if (!can_draw_3d) { RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas); } else { @@ -547,12 +553,12 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { } if (scenario_draw_canvas_bg) { + // There may be an outstanding clear request if a clear was requested, but no 2D elements were drawn. + // Clear now otherwise we copy over garbage from the render target. + RSG::texture_storage->render_target_do_clear_request(p_viewport->render_target); if (!can_draw_3d) { RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas); } else { - // There may be an outstanding clear request if a clear was requested, but no 2D elements were drawn. - // Clear now otherwise we copy over garbage from the render target. - RSG::texture_storage->render_target_do_clear_request(p_viewport->render_target); _draw_3d(p_viewport); } } |