From d67e77e837a63e3900f7dae942d8b58a94a94e0c Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Sat, 21 Oct 2017 02:06:10 -0500 Subject: [PATCH] Fixed viewport transparent bg when clear mode is enabled. --- servers/visual/visual_server_viewport.cpp | 3 ++- servers/visual/visual_server_viewport.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp index 0dca09a5bf6..92c431e393d 100644 --- a/servers/visual/visual_server_viewport.cpp +++ b/servers/visual/visual_server_viewport.cpp @@ -54,7 +54,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E bool can_draw_3d = !p_viewport->disable_3d && !p_viewport->disable_3d_by_usage && VSG::scene->camera_owner.owns(p_viewport->camera); if (p_viewport->clear_mode != VS::VIEWPORT_CLEAR_NEVER) { - VSG::rasterizer->clear_render_target(clear_color); + VSG::rasterizer->clear_render_target(p_viewport->transparent_bg ? Color(0, 0, 0, 0) : clear_color); if (p_viewport->clear_mode == VS::VIEWPORT_CLEAR_ONLY_NEXT_FRAME) { p_viewport->clear_mode = VS::VIEWPORT_CLEAR_NEVER; } @@ -504,6 +504,7 @@ void VisualServerViewport::viewport_set_transparent_background(RID p_viewport, b ERR_FAIL_COND(!viewport); VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_TRANSPARENT, p_enabled); + viewport->transparent_bg = true; } void VisualServerViewport::viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) { diff --git a/servers/visual/visual_server_viewport.h b/servers/visual/visual_server_viewport.h index 8a294a9129a..8db6eda133c 100644 --- a/servers/visual/visual_server_viewport.h +++ b/servers/visual/visual_server_viewport.h @@ -72,6 +72,8 @@ public: VS::ViewportClearMode clear_mode; + bool transparent_bg; + struct CanvasKey { int layer; @@ -101,6 +103,7 @@ public: Viewport() { update_mode = VS::VIEWPORT_UPDATE_WHEN_VISIBLE; clear_mode = VS::VIEWPORT_CLEAR_ALWAYS; + transparent_bg = false; disable_environment = false; viewport_to_screen = 0; shadow_atlas_size = 0;