From 0399c84848aeae1ea5ee836e1852e59cacae82c7 Mon Sep 17 00:00:00 2001 From: Christian Mattes <christian.mattes@rwth-aachen.de> Date: Wed, 3 Aug 2016 18:54:45 +0200 Subject: [PATCH] Changed Renderpipeline to allow for Postprocesses, which use the current color instead of blending to it --- pipeline/glow-extras/pipeline/RenderPass.hh | 3 +++ pipeline/glow-extras/pipeline/RenderingPipeline.cc | 13 +++++++++++-- pipeline/glow-extras/pipeline/RenderingPipeline.hh | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pipeline/glow-extras/pipeline/RenderPass.hh b/pipeline/glow-extras/pipeline/RenderPass.hh index 26af14e..b97a52f 100644 --- a/pipeline/glow-extras/pipeline/RenderPass.hh +++ b/pipeline/glow-extras/pipeline/RenderPass.hh @@ -35,6 +35,9 @@ struct RenderPass SharedTextureRectangle depthTarget = nullptr; /// Currently bound framebuffer SharedFramebuffer framebuffer = nullptr; + + /// Current color texture (different from the bound one in destructive PostProcess) + SharedTextureRectangle colorTexture = nullptr; }; } } diff --git a/pipeline/glow-extras/pipeline/RenderingPipeline.cc b/pipeline/glow-extras/pipeline/RenderingPipeline.cc index 6ad0342..f5fa5d6 100644 --- a/pipeline/glow-extras/pipeline/RenderingPipeline.cc +++ b/pipeline/glow-extras/pipeline/RenderingPipeline.cc @@ -180,11 +180,20 @@ void RenderingPipeline::render(const std::function<void(RenderPass const& pass)> rp.pipeline = this; rp.camera = &cam; rp.depthTarget = mTargetDepth; - rp.framebuffer = (toColorTmp ? mFboToColor : mFboToColorTmp); + rp.colorTexture = (toColorTmp ? mTargetColor : mTargetColorTmp); - auto fbo = (toColorTmp ? mFboToColor : mFboToColorTmp)->bind(); + // For destructive postprocess, bind the other framebuffer + rp.framebuffer = ((toColorTmp != mDestructivePostprocess) + ? mFboToColor + : mFboToColorTmp); + + if (mDestructivePostprocess) glClear(GL_COLOR_BUFFER_BIT); + + auto fbo = rp.framebuffer->bind(); renderFunc(rp); + + if (mDestructivePostprocess) toColorTmp = !toColorTmp; } // Transparency resolve diff --git a/pipeline/glow-extras/pipeline/RenderingPipeline.hh b/pipeline/glow-extras/pipeline/RenderingPipeline.hh index bc37433..35b2c48 100644 --- a/pipeline/glow-extras/pipeline/RenderingPipeline.hh +++ b/pipeline/glow-extras/pipeline/RenderingPipeline.hh @@ -96,6 +96,10 @@ private: float mDitheringStrength = 1 / 256.f; glm::vec3 mClearColor; + // true if the postprocess should use the color target as an input + // instead of blending to it + bool mDestructivePostprocess = false; + public: // getter, setter GLOW_PROPERTY(Camera); @@ -106,6 +110,7 @@ public: // getter, setter GLOW_PROPERTY(DitheringStrength); GLOW_PROPERTY(TransparentPass); GLOW_PROPERTY(ClearColor); + GLOW_PROPERTY(DestructivePostprocess); int getOutputWidth() const; int getOutputHeight() const; -- GitLab