Commit 0399c848 authored by Christian Mattes's avatar Christian Mattes

Changed Renderpipeline to allow for Postprocesses, which use the current color...

Changed Renderpipeline to allow for Postprocesses, which use the current color instead of blending to it
parent 962b723e
......@@ -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;
};
}
}
......@@ -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
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment