diff options
11 files changed, 78 insertions, 10 deletions
diff --git a/src/Runtime/Source/Engine/Source/Qt3DSRenderRuntimeBinding.cpp b/src/Runtime/Source/Engine/Source/Qt3DSRenderRuntimeBinding.cpp index 39667e74..36f3b28c 100644 --- a/src/Runtime/Source/Engine/Source/Qt3DSRenderRuntimeBinding.cpp +++ b/src/Runtime/Source/Engine/Source/Qt3DSRenderRuntimeBinding.cpp @@ -113,6 +113,9 @@ struct Qt3DSRenderSceneSubPresRenderer : public CSubPresentationRenderer void Render(const SOffscreenRendererEnvironment &inEnvironment, NVRenderContext &inRenderContext, QT3DSVec2 inPresScale, SScene::RenderClearCommand inClearBuffer) override; + void RenderWithClear(const SOffscreenRendererEnvironment &inEnvironment, + NVRenderContext &inRenderContext, QT3DSVec2 inPresScale, + SScene::RenderClearCommand inClearBuffer, QT3DSVec3 inClearColor); }; struct SSceneLoadData @@ -795,6 +798,16 @@ void Qt3DSRenderSceneSubPresRenderer::Render(const SOffscreenRendererEnvironment CSubPresentationRenderer::Render(inEnvironment, inRenderContext, inPresScale, inClearBuffer); } +void Qt3DSRenderSceneSubPresRenderer::RenderWithClear( + const SOffscreenRendererEnvironment &inEnvironment, + NVRenderContext &inRenderContext, QT3DSVec2 inPresScale, + SScene::RenderClearCommand inClearBuffer, QT3DSVec3 inClearColor) +{ + CSubPresentationRenderer::RenderWithClear(inEnvironment, inRenderContext, + inPresScale, inClearBuffer, + inClearColor); +} + ////////////////////////////////////////////////////////////////// // Scene Manager ////////////////////////////////////////////////////////////////// diff --git a/src/Runtime/Source/Qt3DSRuntimeRender/GraphObjects/Qt3DSRenderScene.cpp b/src/Runtime/Source/Qt3DSRuntimeRender/GraphObjects/Qt3DSRenderScene.cpp index cee88e51..d510c49c 100644 --- a/src/Runtime/Source/Qt3DSRuntimeRender/GraphObjects/Qt3DSRenderScene.cpp +++ b/src/Runtime/Source/Qt3DSRuntimeRender/GraphObjects/Qt3DSRenderScene.cpp @@ -104,7 +104,8 @@ void SScene::Render(const QT3DSVec2 &inViewportDimensions, IQt3DSRenderContext & { if ((inClearColorBuffer == SScene::ClearIsOptional && m_UseClearColor) || inClearColorBuffer == SScene::AlwaysClear) { - QT3DSF32 clearColorAlpha = inContext.IsInSubPresentation() ? 0.0f : 1.0f; + QT3DSF32 clearColorAlpha + = inContext.IsInSubPresentation() && !m_UseClearColor ? 0.0f : 1.0f; QT3DSVec4 clearColor(0.0f, 0.0f, 0.0f, clearColorAlpha); if (m_UseClearColor) { clearColor.x = m_ClearColor.x; @@ -121,3 +122,16 @@ void SScene::Render(const QT3DSVec2 &inViewportDimensions, IQt3DSRenderContext & inContext.GetRenderer().RenderLayer(*m_FirstChild, inViewportDimensions, m_UseClearColor, m_ClearColor, true); } +void SScene::RenderWithClear(const QT3DSVec2 &inViewportDimensions, IQt3DSRenderContext &inContext, + RenderClearCommand inClearColorBuffer, QT3DSVec3 inClearColor) +{ + // If this scene is not using clear color, we set the color + // to background color from parent layer. This allows + // fully transparent subpresentations (both scene and layer(s) transparent) + // to inherit color from the layer that contains them. + if (!m_UseClearColor) { + m_ClearColor = inClearColor; + m_UseClearColor = true; + } + Render(inViewportDimensions, inContext, inClearColorBuffer); +} diff --git a/src/Runtime/Source/Qt3DSRuntimeRender/GraphObjects/Qt3DSRenderScene.h b/src/Runtime/Source/Qt3DSRuntimeRender/GraphObjects/Qt3DSRenderScene.h index 42f506c9..210e49ad 100644 --- a/src/Runtime/Source/Qt3DSRuntimeRender/GraphObjects/Qt3DSRenderScene.h +++ b/src/Runtime/Source/Qt3DSRuntimeRender/GraphObjects/Qt3DSRenderScene.h @@ -77,6 +77,8 @@ namespace render { bool PrepareForRender(const QT3DSVec2 &inViewportDimensions, IQt3DSRenderContext &inContext); void Render(const QT3DSVec2 &inViewportDimensions, IQt3DSRenderContext &inContext, RenderClearCommand command = ClearIsOptional); + void RenderWithClear(const QT3DSVec2 &inViewportDimensions, IQt3DSRenderContext &inContext, + RenderClearCommand inClearColorBuffer, QT3DSVec3 inclearColor); }; } } diff --git a/src/Runtime/Source/Qt3DSRuntimeRender/Include/Qt3DSOffscreenRenderManager.h b/src/Runtime/Source/Qt3DSRuntimeRender/Include/Qt3DSOffscreenRenderManager.h index 16132ba7..0be417a5 100644 --- a/src/Runtime/Source/Qt3DSRuntimeRender/Include/Qt3DSOffscreenRenderManager.h +++ b/src/Runtime/Source/Qt3DSRuntimeRender/Include/Qt3DSOffscreenRenderManager.h @@ -152,6 +152,10 @@ namespace render { virtual void Render(const SOffscreenRendererEnvironment &inEnvironment, NVRenderContext &inRenderContext, QT3DSVec2 inPresentationScaleFactor, SScene::RenderClearCommand inColorBufferNeedsClear) = 0; + virtual void RenderWithClear(const SOffscreenRendererEnvironment &inEnvironment, + NVRenderContext &inRenderContext, QT3DSVec2 inPresentationScaleFactor, + SScene::RenderClearCommand inColorBufferNeedsClear, + QT3DSVec3 inclearColor) = 0; // Implementors should implement one of the two interfaces below. diff --git a/src/Runtime/Source/Qt3DSRuntimeRender/Include/Qt3DSOldNBustedRenderPlugin.h b/src/Runtime/Source/Qt3DSRuntimeRender/Include/Qt3DSOldNBustedRenderPlugin.h index 8c46cca2..15803c34 100644 --- a/src/Runtime/Source/Qt3DSRuntimeRender/Include/Qt3DSOldNBustedRenderPlugin.h +++ b/src/Runtime/Source/Qt3DSRuntimeRender/Include/Qt3DSOldNBustedRenderPlugin.h @@ -69,6 +69,10 @@ namespace render { NVRenderContext & /*inRenderContext*/ , QT3DSVec2 inPresScale, SScene::RenderClearCommand inClearBuffer) override; + void RenderWithClear(const SOffscreenRendererEnvironment &inEnvironment, + NVRenderContext &inRenderContext, QT3DSVec2 inPresentationScaleFactor, + SScene::RenderClearCommand inColorBufferNeedsClear, + QT3DSVec3 inclearColor) override {} IGraphObjectPickQuery *GetGraphObjectPickQuery() override { return NULL; } bool Pick(const QT3DSVec2 & /*inMouseCoords*/, const QT3DSVec2 & /*inViewportDimensions*/) override { diff --git a/src/Runtime/Source/Qt3DSRuntimeRender/Include/Qt3DSRenderSubpresentation.h b/src/Runtime/Source/Qt3DSRuntimeRender/Include/Qt3DSRenderSubpresentation.h index 97371edc..89ab3d9d 100644 --- a/src/Runtime/Source/Qt3DSRuntimeRender/Include/Qt3DSRenderSubpresentation.h +++ b/src/Runtime/Source/Qt3DSRuntimeRender/Include/Qt3DSRenderSubpresentation.h @@ -79,6 +79,10 @@ namespace render { NVRenderContext & /*inRenderContext*/ , QT3DSVec2 inPresScale, SScene::RenderClearCommand inClearBuffer) override; + void RenderWithClear(const SOffscreenRendererEnvironment &inEnvironment, + NVRenderContext &inRenderContext, + QT3DSVec2 inPresScale, SScene::RenderClearCommand inClearBuffer, + QT3DSVec3 inClearColor) override; IGraphObjectPickQuery *GetGraphObjectPickQuery() override { return &m_PickQuery; } bool Pick(const QT3DSVec2 & /*inMouseCoords*/, const QT3DSVec2 & /*inViewportDimensions*/) override { diff --git a/src/Runtime/Source/Qt3DSRuntimeRender/Include/q3dsqmlrender.h b/src/Runtime/Source/Qt3DSRuntimeRender/Include/q3dsqmlrender.h index 8e285f00..010c206b 100644 --- a/src/Runtime/Source/Qt3DSRuntimeRender/Include/q3dsqmlrender.h +++ b/src/Runtime/Source/Qt3DSRuntimeRender/Include/q3dsqmlrender.h @@ -59,6 +59,10 @@ public: void Render(const SOffscreenRendererEnvironment &inEnvironment, NVRenderContext &inRenderContext, QT3DSVec2 inPresentationScaleFactor, SScene::RenderClearCommand inColorBufferNeedsClear) override; + void RenderWithClear(const SOffscreenRendererEnvironment &inEnvironment, + NVRenderContext &inRenderContext, QT3DSVec2 inPresentationScaleFactor, + SScene::RenderClearCommand inColorBufferNeedsClear, + QT3DSVec3 inclearColor) override {} IGraphObjectPickQuery *GetGraphObjectPickQuery() override { diff --git a/src/Runtime/Source/Qt3DSRuntimeRender/RendererImpl/Qt3DSRendererImplLayerRenderData.cpp b/src/Runtime/Source/Qt3DSRuntimeRender/RendererImpl/Qt3DSRendererImplLayerRenderData.cpp index 50040a99..301e66df 100644 --- a/src/Runtime/Source/Qt3DSRuntimeRender/RendererImpl/Qt3DSRendererImplLayerRenderData.cpp +++ b/src/Runtime/Source/Qt3DSRuntimeRender/RendererImpl/Qt3DSRendererImplLayerRenderData.cpp @@ -1172,10 +1172,17 @@ namespace render { { if (m_LayerPrepResult->IsLayerVisible()) { if (GetOffscreenRenderer()) { - m_LastFrameOffscreenRenderer->Render( - CreateOffscreenRenderEnvironment(), m_Renderer.GetContext(), - m_Renderer.GetQt3DSContext().GetPresentationScaleFactor(), - SScene::ClearIsOptional); + if (m_Layer.m_Background == LayerBackground::Color) { + m_LastFrameOffscreenRenderer->RenderWithClear( + CreateOffscreenRenderEnvironment(), m_Renderer.GetContext(), + m_Renderer.GetQt3DSContext().GetPresentationScaleFactor(), + SScene::AlwaysClear, m_Layer.m_ClearColor); + } else { + m_LastFrameOffscreenRenderer->Render( + CreateOffscreenRenderEnvironment(), m_Renderer.GetContext(), + m_Renderer.GetQt3DSContext().GetPresentationScaleFactor(), + SScene::ClearIsOptional); + } } else { RenderDepthPass(false); Render(); diff --git a/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSRenderContextCore.cpp b/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSRenderContextCore.cpp index ecf3adbe..dbf5dbad 100644 --- a/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSRenderContextCore.cpp +++ b/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSRenderContextCore.cpp @@ -681,15 +681,12 @@ struct SRenderContext : public IQt3DSRenderContext } else { m_RenderContext->SetScissorTestEnabled(false); } - bool clearedScene = false; { QT3DSVec4 theClearColor; if (m_MatteColor.hasValue()) theClearColor = m_MatteColor; - else { + else theClearColor = m_SceneColor; - clearedScene = true; - } m_RenderContext->SetClearColor(theClearColor); m_RenderContext->Clear(qt3ds::render::NVRenderClearValues::Color); } @@ -708,7 +705,8 @@ struct SRenderContext : public IQt3DSRenderContext m_RotationTexture = NULL; m_RotationDepthBuffer = NULL; } - if (m_SceneColor.hasValue() && !clearedScene) { + bool clear = m_SceneColor.getValue().w == 0.0f ? false : true; + if (m_SceneColor.hasValue() && clear) { m_RenderContext->SetClearColor(m_SceneColor); m_RenderContext->Clear(qt3ds::render::NVRenderClearValues::Color); } diff --git a/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSRenderPlugin.cpp b/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSRenderPlugin.cpp index 98abb868..987708c2 100644 --- a/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSRenderPlugin.cpp +++ b/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSRenderPlugin.cpp @@ -384,6 +384,13 @@ struct InstanceImpl : public IRenderPluginInstance } } + void RenderWithClear(const SOffscreenRendererEnvironment &inEnvironment, + NVRenderContext &inRenderContext, QT3DSVec2 inPresScale, + SScene::RenderClearCommand inClearBuffer, QT3DSVec3 inClearColor) + { + Q_ASSERT(false); + } + // Implementors should implement one of the two interfaces below. // If this renderer supports picking that can return graph objects diff --git a/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSRenderSubpresentation.cpp b/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSRenderSubpresentation.cpp index b4752a2b..56d0e98d 100644 --- a/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSRenderSubpresentation.cpp +++ b/src/Runtime/Source/Qt3DSRuntimeRender/Source/Qt3DSRenderSubpresentation.cpp @@ -94,6 +94,17 @@ namespace render { m_LastRenderedEnvironment = inEnvironment; } + void CSubPresentationRenderer::RenderWithClear( + const SOffscreenRendererEnvironment &inEnvironment, + NVRenderContext &inRenderContext, QT3DSVec2 inPresScale, + SScene::RenderClearCommand inClearBuffer, QT3DSVec3 inClearColor) + { + NVRenderRect theViewportSize(inRenderContext.GetViewport()); + m_Presentation.m_Scene->RenderWithClear( + QT3DSVec2((QT3DSF32)theViewportSize.m_Width, (QT3DSF32)theViewportSize.m_Height), + m_RenderContext, inClearBuffer, inClearColor); + } + // You know the viewport dimensions because Qt3DSRenderPickResult CSubPresentationRenderer::DoGraphQueryPick( const QT3DSVec2 &inMouseCoords, const QT3DSVec2 &inViewportDimensions, bool inPickEverything) |