Merge pull request #12276 from djrm/pr_vp_fixes

Fixed viewport transparent bg when clear mode is enabled.
This commit is contained in:
Rémi Verschelde 2017-10-21 11:36:09 +02:00 committed by GitHub
commit f3f15965c0
2 changed files with 5 additions and 1 deletions

View file

@ -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); 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) { 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) { if (p_viewport->clear_mode == VS::VIEWPORT_CLEAR_ONLY_NEXT_FRAME) {
p_viewport->clear_mode = VS::VIEWPORT_CLEAR_NEVER; 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); ERR_FAIL_COND(!viewport);
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_TRANSPARENT, p_enabled); 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) { void VisualServerViewport::viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) {

View file

@ -72,6 +72,8 @@ public:
VS::ViewportClearMode clear_mode; VS::ViewportClearMode clear_mode;
bool transparent_bg;
struct CanvasKey { struct CanvasKey {
int layer; int layer;
@ -101,6 +103,7 @@ public:
Viewport() { Viewport() {
update_mode = VS::VIEWPORT_UPDATE_WHEN_VISIBLE; update_mode = VS::VIEWPORT_UPDATE_WHEN_VISIBLE;
clear_mode = VS::VIEWPORT_CLEAR_ALWAYS; clear_mode = VS::VIEWPORT_CLEAR_ALWAYS;
transparent_bg = false;
disable_environment = false; disable_environment = false;
viewport_to_screen = 0; viewport_to_screen = 0;
shadow_atlas_size = 0; shadow_atlas_size = 0;