From c36e04c435ef9c5c4a6e43dad1badd0533f424bf Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 9 Dec 2013 11:21:32 -0800 Subject: [PATCH] This should fix the erroneous persistence on startup. --- interface/src/renderer/GlowEffect.cpp | 10 +++++++--- interface/src/renderer/GlowEffect.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/interface/src/renderer/GlowEffect.cpp b/interface/src/renderer/GlowEffect.cpp index fe46e02688..51128bf1c3 100644 --- a/interface/src/renderer/GlowEffect.cpp +++ b/interface/src/renderer/GlowEffect.cpp @@ -19,6 +19,7 @@ GlowEffect::GlowEffect() : _initialized(false), _renderMode(DIFFUSE_ADD_MODE), _isOddFrame(false), + _isFirstFrame(true), _intensity(0.0f) { } @@ -167,7 +168,7 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) { newDiffusedFBO->bind(); glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, oldDiffusedFBO->texture()); + glBindTexture(GL_TEXTURE_2D, _isFirstFrame ? 0 : oldDiffusedFBO->texture()); _diffuseProgram->bind(); QSize size = Application::getInstance()->getGLWidget()->size(); @@ -221,7 +222,7 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) { maybeRelease(destFBO); } else { // _renderMode == BLUR_PERSIST_ADD_MODE - // render the secondary to the tertiary with horizontal blur and persistence + // render the secondary to the tertiary with vertical blur and persistence QOpenGLFramebufferObject* tertiaryFBO = Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject(); tertiaryFBO->bind(); @@ -229,7 +230,7 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) { glEnable(GL_BLEND); glBlendFunc(GL_ONE_MINUS_CONSTANT_ALPHA, GL_CONSTANT_ALPHA); const float PERSISTENCE_SMOOTHING = 0.9f; - glBlendColor(0.0f, 0.0f, 0.0f, PERSISTENCE_SMOOTHING); + glBlendColor(0.0f, 0.0f, 0.0f, _isFirstFrame ? 0.0f : PERSISTENCE_SMOOTHING); glBindTexture(GL_TEXTURE_2D, secondaryFBO->texture()); @@ -270,6 +271,8 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) { glDepthMask(GL_TRUE); glBindTexture(GL_TEXTURE_2D, 0); + _isFirstFrame = false; + return destFBO; } @@ -292,6 +295,7 @@ void GlowEffect::cycleRenderMode() { qDebug() << "Glow mode: Diffuse/add\n"; break; } + _isFirstFrame = true; } Glower::Glower(float amount) { diff --git a/interface/src/renderer/GlowEffect.h b/interface/src/renderer/GlowEffect.h index 8168ae4374..65d3d6c8ce 100644 --- a/interface/src/renderer/GlowEffect.h +++ b/interface/src/renderer/GlowEffect.h @@ -66,6 +66,7 @@ private: bool _isEmpty; ///< set when nothing in the scene is currently glowing bool _isOddFrame; ///< controls the alternation between texture targets in diffuse add mode + bool _isFirstFrame; ///< for persistent modes, notes whether this is the first frame rendered float _intensity; QStack _intensityStack;