From 15f129f32d3b4ac3d833104e6595b4137fca658b Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 14 Aug 2013 14:14:47 -0700 Subject: [PATCH 01/15] Added simple additive/blur-with-persist glow modes, means to cycle through modes. --- interface/resources/shaders/glow_add.frag | 17 ++++ .../resources/shaders/glow_add_separate.frag | 20 +++++ .../resources/shaders/vertical_blur.frag | 24 +++--- .../resources/shaders/vertical_blur_add.frag | 28 +++++++ interface/src/Application.cpp | 5 ++ interface/src/renderer/GlowEffect.cpp | 83 +++++++++++++++---- interface/src/renderer/GlowEffect.h | 18 +++- interface/src/renderer/TextureCache.cpp | 17 +++- interface/src/renderer/TextureCache.h | 4 +- 9 files changed, 185 insertions(+), 31 deletions(-) create mode 100644 interface/resources/shaders/glow_add.frag create mode 100644 interface/resources/shaders/glow_add_separate.frag create mode 100644 interface/resources/shaders/vertical_blur_add.frag diff --git a/interface/resources/shaders/glow_add.frag b/interface/resources/shaders/glow_add.frag new file mode 100644 index 0000000000..0947292109 --- /dev/null +++ b/interface/resources/shaders/glow_add.frag @@ -0,0 +1,17 @@ +#version 120 + +// +// glow_add.frag +// fragment shader +// +// Created by Andrzej Kapolka on 8/14/13. +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// + +// the texture containing the original color +uniform sampler2D originalTexture; + +void main(void) { + vec4 color = texture2D(originalTexture, gl_TexCoord[0].st); + gl_FragColor = color * (1.0 + color.a); +} diff --git a/interface/resources/shaders/glow_add_separate.frag b/interface/resources/shaders/glow_add_separate.frag new file mode 100644 index 0000000000..7b7f538a03 --- /dev/null +++ b/interface/resources/shaders/glow_add_separate.frag @@ -0,0 +1,20 @@ +#version 120 + +// +// glow_add_separate.frag +// fragment shader +// +// Created by Andrzej Kapolka on 8/14/13. +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// + +// the texture containing the original color +uniform sampler2D originalTexture; + +// the texture containing the blurred color +uniform sampler2D blurredTexture; + +void main(void) { + vec4 blurred = texture2D(blurredTexture, gl_TexCoord[0].st); + gl_FragColor = blurred * blurred.a + texture2D(originalTexture, gl_TexCoord[0].st) * (1.0 + blurred.a * 0.5); +} diff --git a/interface/resources/shaders/vertical_blur.frag b/interface/resources/shaders/vertical_blur.frag index 6e49c5b553..96ab95ea9e 100644 --- a/interface/resources/shaders/vertical_blur.frag +++ b/interface/resources/shaders/vertical_blur.frag @@ -4,25 +4,21 @@ // vertical_blur.frag // fragment shader // -// Created by Andrzej Kapolka on 8/8/13. +// Created by Andrzej Kapolka on 8/14/13. // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // -// the texture containing the original color -uniform sampler2D originalTexture; - // the texture containing the horizontally blurred color -uniform sampler2D horizontallyBlurredTexture; +uniform sampler2D originalTexture; void main(void) { float dt = dFdy(gl_TexCoord[0].t); - vec4 blurred = (texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -7.5)) + - texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -5.5)) + - texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -3.5)) + - texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -1.5)) + - texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 1.5)) + - texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 3.5)) + - texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 5.5)) + - texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 7.5))) / 8.0; - gl_FragColor = blurred * blurred.a + texture2D(originalTexture, gl_TexCoord[0].st) * (1.0 + blurred.a * 0.5); + gl_FragColor = (texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * -7.5)) + + texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * -5.5)) + + texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * -3.5)) + + texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * -1.5)) + + texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * 1.5)) + + texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * 3.5)) + + texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * 5.5)) + + texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * 7.5))) / 8.0; } diff --git a/interface/resources/shaders/vertical_blur_add.frag b/interface/resources/shaders/vertical_blur_add.frag new file mode 100644 index 0000000000..5cda2622b4 --- /dev/null +++ b/interface/resources/shaders/vertical_blur_add.frag @@ -0,0 +1,28 @@ +#version 120 + +// +// vertical_blur_add.frag +// fragment shader +// +// Created by Andrzej Kapolka on 8/8/13. +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// + +// the texture containing the original color +uniform sampler2D originalTexture; + +// the texture containing the horizontally blurred color +uniform sampler2D horizontallyBlurredTexture; + +void main(void) { + float dt = dFdy(gl_TexCoord[0].t); + vec4 blurred = (texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -7.5)) + + texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -5.5)) + + texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -3.5)) + + texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -1.5)) + + texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 1.5)) + + texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 3.5)) + + texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 5.5)) + + texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 7.5))) / 8.0; + gl_FragColor = blurred * blurred.a + texture2D(originalTexture, gl_TexCoord[0].st) * (1.0 + blurred.a * 0.5); +} diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index eebb7ba744..65b2da4c24 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2011,6 +2011,7 @@ void Application::initMenu() { _renderAvatarBalls->setChecked(false); renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode())); renderMenu->addAction("Cycle Face Mode", &_myAvatar.getHead().getFace(), SLOT(cycleRenderMode())); + renderMenu->addAction("Cycle Glow Mode", &_glowEffect, SLOT(cycleRenderMode())); (_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true); _renderFrameTimerOn->setChecked(false); (_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true); @@ -3162,7 +3163,9 @@ void Application::displaySide(Camera& whichCamera) { if (isLookingAtMyAvatar(avatar)) { avatar->getHead().setLookAtPosition(_myCamera.getPosition()); } + _glowEffect.begin(); avatar->render(false, _renderAvatarBalls->isChecked()); + _glowEffect.end(); avatar->setDisplayingLookatVectors(_renderLookatOn->isChecked()); } @@ -3173,7 +3176,9 @@ void Application::displaySide(Camera& whichCamera) { if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { _myAvatar.getHead().setLookAtPosition(_myCamera.getPosition()); } + _glowEffect.begin(); _myAvatar.render(_lookingInMirror->isChecked(), _renderAvatarBalls->isChecked()); + _glowEffect.end(); _myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked()); diff --git a/interface/src/renderer/GlowEffect.cpp b/interface/src/renderer/GlowEffect.cpp index 11c73dd12d..8233fe1984 100644 --- a/interface/src/renderer/GlowEffect.cpp +++ b/interface/src/renderer/GlowEffect.cpp @@ -14,9 +14,12 @@ #include "GlowEffect.h" #include "ProgramObject.h" -static ProgramObject* createBlurProgram(const QString& direction) { +GlowEffect::GlowEffect() : _renderMode(BLUR_ADD_MODE) { +} + +static ProgramObject* createProgram(const QString& name) { ProgramObject* program = new ProgramObject(); - program->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/" + direction + "_blur.frag"); + program->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/" + name + ".frag"); program->link(); program->bind(); @@ -28,12 +31,20 @@ static ProgramObject* createBlurProgram(const QString& direction) { void GlowEffect::init() { switchToResourcesParentIfRequired(); - _horizontalBlurProgram = createBlurProgram("horizontal"); - _verticalBlurProgram = createBlurProgram("vertical"); - _verticalBlurProgram->bind(); - _verticalBlurProgram->setUniformValue("horizontallyBlurredTexture", 1); - _verticalBlurProgram->release(); + _addProgram = createProgram("glow_add"); + _horizontalBlurProgram = createProgram("horizontal_blur"); + _verticalBlurAddProgram = createProgram("vertical_blur_add"); + _verticalBlurProgram = createProgram("vertical_blur"); + _addSeparateProgram = createProgram("glow_add_separate"); + + _verticalBlurAddProgram->bind(); + _verticalBlurAddProgram->setUniformValue("horizontallyBlurredTexture", 1); + _verticalBlurAddProgram->release(); + + _addSeparateProgram->bind(); + _addSeparateProgram->setUniformValue("blurredTexture", 1); + _addSeparateProgram->release(); } void GlowEffect::prepare() { @@ -93,7 +104,12 @@ void GlowEffect::render() { glDisable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); } - } else { + } else if (_renderMode == ADD_MODE) { + _addProgram->bind(); + renderFullscreenQuad(); + _addProgram->release(); + + } else { // _renderMode == BLUR_ADD_MODE || _renderMode == BLUR_PERSIST_ADD_MODE // render the primary to the secondary with the horizontal blur QOpenGLFramebufferObject* secondaryFBO = Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject(); @@ -105,13 +121,48 @@ void GlowEffect::render() { secondaryFBO->release(); - // render the secondary to the screen with the vertical blur - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, secondaryFBO->texture()); + if (_renderMode == BLUR_ADD_MODE) { + // render the secondary to the screen with the vertical blur + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, secondaryFBO->texture()); + + _verticalBlurAddProgram->bind(); + renderFullscreenQuad(); + _verticalBlurAddProgram->release(); + + } else { // _renderMode == BLUR_PERSIST_ADD_MODE + // render the secondary to the tertiary with horizontal blur and persistence + QOpenGLFramebufferObject* tertiaryFBO = + Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject(); + tertiaryFBO->bind(); + + 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); + + glBindTexture(GL_TEXTURE_2D, secondaryFBO->texture()); + + _verticalBlurProgram->bind(); + renderFullscreenQuad(); + _verticalBlurProgram->release(); - _verticalBlurProgram->bind(); - renderFullscreenQuad(); - _verticalBlurProgram->release(); + glBlendColor(0.0f, 0.0f, 0.0f, 0.0f); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE); + glDisable(GL_BLEND); + + // now add the tertiary to the primary buffer + tertiaryFBO->release(); + + glBindTexture(GL_TEXTURE_2D, primaryFBO->texture()); + + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, tertiaryFBO->texture()); + + _addSeparateProgram->bind(); + renderFullscreenQuad(); + _addSeparateProgram->release(); + } glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0); @@ -126,3 +177,7 @@ void GlowEffect::render() { glEnable(GL_DEPTH_TEST); glBindTexture(GL_TEXTURE_2D, 0); } + +void GlowEffect::cycleRenderMode() { + _renderMode = (RenderMode)((_renderMode + 1) % RENDER_MODE_COUNT); +} diff --git a/interface/src/renderer/GlowEffect.h b/interface/src/renderer/GlowEffect.h index 06ca6e5712..d8ea3d18c2 100644 --- a/interface/src/renderer/GlowEffect.h +++ b/interface/src/renderer/GlowEffect.h @@ -9,11 +9,17 @@ #ifndef __interface__GlowEffect__ #define __interface__GlowEffect__ +#include + class ProgramObject; -class GlowEffect { +class GlowEffect : public QObject { + Q_OBJECT + public: + GlowEffect(); + void init(); void prepare(); @@ -23,10 +29,20 @@ public: void render(); +public slots: + + void cycleRenderMode(); + private: + enum RenderMode { ADD_MODE, BLUR_ADD_MODE, BLUR_PERSIST_ADD_MODE, RENDER_MODE_COUNT }; + + RenderMode _renderMode; + ProgramObject* _addProgram; ProgramObject* _horizontalBlurProgram; + ProgramObject* _verticalBlurAddProgram; ProgramObject* _verticalBlurProgram; + ProgramObject* _addSeparateProgram; bool _isEmpty; }; diff --git a/interface/src/renderer/TextureCache.cpp b/interface/src/renderer/TextureCache.cpp index 8ff1673d18..d4cc97edbf 100644 --- a/interface/src/renderer/TextureCache.cpp +++ b/interface/src/renderer/TextureCache.cpp @@ -14,7 +14,7 @@ #include "TextureCache.h" TextureCache::TextureCache() : _permutationNormalTextureID(0), - _primaryFramebufferObject(NULL), _secondaryFramebufferObject(NULL) { + _primaryFramebufferObject(NULL), _secondaryFramebufferObject(NULL), _tertiaryFramebufferObject(NULL) { } TextureCache::~TextureCache() { @@ -27,6 +27,9 @@ TextureCache::~TextureCache() { if (_secondaryFramebufferObject != NULL) { delete _secondaryFramebufferObject; } + if (_tertiaryFramebufferObject != NULL) { + delete _tertiaryFramebufferObject; + } } GLuint TextureCache::getPermutationNormalTextureID() { @@ -72,6 +75,14 @@ QOpenGLFramebufferObject* TextureCache::getSecondaryFramebufferObject() { return _secondaryFramebufferObject; } +QOpenGLFramebufferObject* TextureCache::getTertiaryFramebufferObject() { + if (_tertiaryFramebufferObject == NULL) { + _tertiaryFramebufferObject = new QOpenGLFramebufferObject(Application::getInstance()->getGLWidget()->size()); + Application::getInstance()->getGLWidget()->installEventFilter(this); + } + return _tertiaryFramebufferObject; +} + bool TextureCache::eventFilter(QObject* watched, QEvent* event) { if (event->type() == QEvent::Resize) { QSize size = static_cast(event)->size(); @@ -83,6 +94,10 @@ bool TextureCache::eventFilter(QObject* watched, QEvent* event) { delete _secondaryFramebufferObject; _secondaryFramebufferObject = NULL; } + if (_tertiaryFramebufferObject != NULL && _tertiaryFramebufferObject->size() != size) { + delete _tertiaryFramebufferObject; + _tertiaryFramebufferObject = NULL; + } } return false; } diff --git a/interface/src/renderer/TextureCache.h b/interface/src/renderer/TextureCache.h index 29920e1f1f..716f087992 100644 --- a/interface/src/renderer/TextureCache.h +++ b/interface/src/renderer/TextureCache.h @@ -25,7 +25,8 @@ public: QOpenGLFramebufferObject* getPrimaryFramebufferObject(); QOpenGLFramebufferObject* getSecondaryFramebufferObject(); - + QOpenGLFramebufferObject* getTertiaryFramebufferObject(); + virtual bool eventFilter(QObject* watched, QEvent* event); private: @@ -34,6 +35,7 @@ private: QOpenGLFramebufferObject* _primaryFramebufferObject; QOpenGLFramebufferObject* _secondaryFramebufferObject; + QOpenGLFramebufferObject* _tertiaryFramebufferObject; }; #endif /* defined(__interface__TextureCache__) */ From a9ccca3f72bcac0ba7e0851f2320194f8f3a7dff Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 14 Aug 2013 16:13:30 -0700 Subject: [PATCH 02/15] Diffuse/add glow mode. --- interface/resources/shaders/diffuse.frag | 28 ++++++++++++++++++ interface/src/renderer/GlowEffect.cpp | 37 +++++++++++++++++++++++- interface/src/renderer/GlowEffect.h | 4 ++- 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 interface/resources/shaders/diffuse.frag diff --git a/interface/resources/shaders/diffuse.frag b/interface/resources/shaders/diffuse.frag new file mode 100644 index 0000000000..f8be7075db --- /dev/null +++ b/interface/resources/shaders/diffuse.frag @@ -0,0 +1,28 @@ +#version 120 + +// +// diffuse.frag +// fragment shader +// +// Created by Andrzej Kapolka on 8/14/13. +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// + +// the texture containing the original color +uniform sampler2D originalTexture; + +// the texture containing the diffused color +uniform sampler2D diffusedTexture; + +void main(void) { + float ds = dFdx(gl_TexCoord[0].s); + float dt = dFdy(gl_TexCoord[0].t); + gl_FragColor = (texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(-ds, -dt)) + + texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(0.0, -dt)) + + texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(ds, -dt)) + + texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(ds, 0.0)) + + texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(ds, dt)) + + texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(0.0, dt)) + + texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(-ds, dt)) + + texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(-ds, 0.0))) / 8.5 + texture2D(originalTexture, gl_TexCoord[0].st) * 0.1; +} diff --git a/interface/src/renderer/GlowEffect.cpp b/interface/src/renderer/GlowEffect.cpp index 8233fe1984..2be1bc0e8f 100644 --- a/interface/src/renderer/GlowEffect.cpp +++ b/interface/src/renderer/GlowEffect.cpp @@ -14,7 +14,7 @@ #include "GlowEffect.h" #include "ProgramObject.h" -GlowEffect::GlowEffect() : _renderMode(BLUR_ADD_MODE) { +GlowEffect::GlowEffect() : _renderMode(DIFFUSE_ADD_MODE) { } static ProgramObject* createProgram(const QString& name) { @@ -37,6 +37,7 @@ void GlowEffect::init() { _verticalBlurAddProgram = createProgram("vertical_blur_add"); _verticalBlurProgram = createProgram("vertical_blur"); _addSeparateProgram = createProgram("glow_add_separate"); + _diffuseProgram = createProgram("diffuse"); _verticalBlurAddProgram->bind(); _verticalBlurAddProgram->setUniformValue("horizontallyBlurredTexture", 1); @@ -45,6 +46,10 @@ void GlowEffect::init() { _addSeparateProgram->bind(); _addSeparateProgram->setUniformValue("blurredTexture", 1); _addSeparateProgram->release(); + + _diffuseProgram->bind(); + _diffuseProgram->setUniformValue("diffusedTexture", 1); + _diffuseProgram->release(); } void GlowEffect::prepare() { @@ -108,6 +113,36 @@ void GlowEffect::render() { _addProgram->bind(); renderFullscreenQuad(); _addProgram->release(); + + } else if (_renderMode == DIFFUSE_ADD_MODE) { + // diffuse into the secondary/tertiary (alternating between frames) + QOpenGLFramebufferObject* oldDiffusedFBO = + Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject(); + QOpenGLFramebufferObject* newDiffusedFBO = + Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject(); + if ((_isOddFrame = !_isOddFrame)) { + qSwap(oldDiffusedFBO, newDiffusedFBO); + } + newDiffusedFBO->bind(); + + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, oldDiffusedFBO->texture()); + + _diffuseProgram->bind(); + renderFullscreenQuad(); + _diffuseProgram->release(); + + newDiffusedFBO->release(); + + // add diffused texture to the primary + glBindTexture(GL_TEXTURE_2D, newDiffusedFBO->texture()); + + _addSeparateProgram->bind(); + renderFullscreenQuad(); + _addSeparateProgram->release(); + + glBindTexture(GL_TEXTURE_2D, 0); + glActiveTexture(GL_TEXTURE0); } else { // _renderMode == BLUR_ADD_MODE || _renderMode == BLUR_PERSIST_ADD_MODE // render the primary to the secondary with the horizontal blur diff --git a/interface/src/renderer/GlowEffect.h b/interface/src/renderer/GlowEffect.h index d8ea3d18c2..cc01ce840f 100644 --- a/interface/src/renderer/GlowEffect.h +++ b/interface/src/renderer/GlowEffect.h @@ -35,7 +35,7 @@ public slots: private: - enum RenderMode { ADD_MODE, BLUR_ADD_MODE, BLUR_PERSIST_ADD_MODE, RENDER_MODE_COUNT }; + enum RenderMode { ADD_MODE, BLUR_ADD_MODE, BLUR_PERSIST_ADD_MODE, DIFFUSE_ADD_MODE, RENDER_MODE_COUNT }; RenderMode _renderMode; ProgramObject* _addProgram; @@ -43,8 +43,10 @@ private: ProgramObject* _verticalBlurAddProgram; ProgramObject* _verticalBlurProgram; ProgramObject* _addSeparateProgram; + ProgramObject* _diffuseProgram; bool _isEmpty; + bool _isOddFrame; }; #endif /* defined(__interface__GlowEffect__) */ From 7cd1360ba7b3509aed513e82d13a1d7dd022e940 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 14 Aug 2013 16:48:00 -0700 Subject: [PATCH 03/15] Doxygen-style comments. --- interface/src/renderer/GlowEffect.cpp | 4 ++-- interface/src/renderer/GlowEffect.h | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/interface/src/renderer/GlowEffect.cpp b/interface/src/renderer/GlowEffect.cpp index 2be1bc0e8f..dba56f53f7 100644 --- a/interface/src/renderer/GlowEffect.cpp +++ b/interface/src/renderer/GlowEffect.cpp @@ -59,8 +59,8 @@ void GlowEffect::prepare() { _isEmpty = true; } -void GlowEffect::begin(float amount) { - glBlendColor(0.0f, 0.0f, 0.0f, amount); +void GlowEffect::begin(float intensity) { + glBlendColor(0.0f, 0.0f, 0.0f, intensity); _isEmpty = false; } diff --git a/interface/src/renderer/GlowEffect.h b/interface/src/renderer/GlowEffect.h index cc01ce840f..5e34779c76 100644 --- a/interface/src/renderer/GlowEffect.h +++ b/interface/src/renderer/GlowEffect.h @@ -13,6 +13,7 @@ class ProgramObject; +/// A generic full screen glow effect. class GlowEffect : public QObject { Q_OBJECT @@ -22,11 +23,17 @@ public: void init(); + /// Prepares the glow effect for rendering the current frame. To be called before rendering the scene. void prepare(); - void begin(float amount = 1.0f); + /// Starts using the glow effect. + /// \param float intensity the desired glow intensity, from zero to one + void begin(float intensity = 1.0f); + + /// Stops using the glow effect. void end(); + /// Renders the glow effect. To be called after rendering the scene. void render(); public slots: @@ -45,8 +52,8 @@ private: ProgramObject* _addSeparateProgram; ProgramObject* _diffuseProgram; - bool _isEmpty; - bool _isOddFrame; + bool _isEmpty; ///< set when nothing in the scene is currently glowing + bool _isOddFrame; ///< controls the alternation between texture targets in diffuse add mode }; #endif /* defined(__interface__GlowEffect__) */ From 690e2c1965f9b4f28c542430827957538462c80c Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 14 Aug 2013 16:58:04 -0700 Subject: [PATCH 04/15] Blur/add should be the default. --- interface/src/renderer/GlowEffect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/renderer/GlowEffect.cpp b/interface/src/renderer/GlowEffect.cpp index dba56f53f7..ce069bc20b 100644 --- a/interface/src/renderer/GlowEffect.cpp +++ b/interface/src/renderer/GlowEffect.cpp @@ -14,7 +14,7 @@ #include "GlowEffect.h" #include "ProgramObject.h" -GlowEffect::GlowEffect() : _renderMode(DIFFUSE_ADD_MODE) { +GlowEffect::GlowEffect() : _renderMode(BLUR_ADD_MODE) { } static ProgramObject* createProgram(const QString& name) { From ab9d414340fe0ce1f42f34ca1d858bd1faf9bc78 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 14 Aug 2013 17:22:43 -0700 Subject: [PATCH 05/15] Doxygen comment fix. --- interface/src/renderer/GlowEffect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/renderer/GlowEffect.h b/interface/src/renderer/GlowEffect.h index 5e34779c76..0d6e83a7a6 100644 --- a/interface/src/renderer/GlowEffect.h +++ b/interface/src/renderer/GlowEffect.h @@ -27,7 +27,7 @@ public: void prepare(); /// Starts using the glow effect. - /// \param float intensity the desired glow intensity, from zero to one + /// \param intensity the desired glow intensity, from zero to one void begin(float intensity = 1.0f); /// Stops using the glow effect. From 95fee434a74e68dda6eddfb99c55efbc9fdd7e55 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 14 Aug 2013 17:37:50 -0700 Subject: [PATCH 06/15] Don't make the avatars glow; that was just for testing. --- interface/src/Application.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 65b2da4c24..83773ef2a7 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3163,9 +3163,7 @@ void Application::displaySide(Camera& whichCamera) { if (isLookingAtMyAvatar(avatar)) { avatar->getHead().setLookAtPosition(_myCamera.getPosition()); } - _glowEffect.begin(); avatar->render(false, _renderAvatarBalls->isChecked()); - _glowEffect.end(); avatar->setDisplayingLookatVectors(_renderLookatOn->isChecked()); } @@ -3176,9 +3174,7 @@ void Application::displaySide(Camera& whichCamera) { if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { _myAvatar.getHead().setLookAtPosition(_myCamera.getPosition()); } - _glowEffect.begin(); _myAvatar.render(_lookingInMirror->isChecked(), _renderAvatarBalls->isChecked()); - _glowEffect.end(); _myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked()); From 6dd4aaf177db6923d05a201fa21994ca7b2411c9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 15 Aug 2013 16:58:37 -0700 Subject: [PATCH 07/15] add docs job to groovy --- jenkins/jobs.groovy | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jenkins/jobs.groovy b/jenkins/jobs.groovy index 8e5e385332..20929df3a9 100644 --- a/jenkins/jobs.groovy +++ b/jenkins/jobs.groovy @@ -140,3 +140,14 @@ parameterizedJob.with { tasks / 'hudson.plugins.postbuildtask.TaskProperties' / script).setValue(curlCommand) } } + +doxygenJob = hifiJob('docs', false) +doxygenJob.with { + configure { project -> + (project / builders).setValue('') + project / publishers / 'hudson.plugins.doxygen.DoxygenArchiver' { + doxyfilePath 'Doxyfile' + keepAll false + } + } +} \ No newline at end of file From 3f5cf8f7143134059e19ef21726e80381b251dd9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 15 Aug 2013 17:07:12 -0700 Subject: [PATCH 08/15] add missing queue for doxygen job --- jenkins/jobs.groovy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jenkins/jobs.groovy b/jenkins/jobs.groovy index 20929df3a9..afd5e6529a 100644 --- a/jenkins/jobs.groovy +++ b/jenkins/jobs.groovy @@ -150,4 +150,6 @@ doxygenJob.with { keepAll false } } -} \ No newline at end of file +} + +queue doxygenJob \ No newline at end of file From d4be99ae2bbeb4b53b92e578c32b47df11e313df Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 15 Aug 2013 17:17:30 -0700 Subject: [PATCH 09/15] add missing folderWhereYouRunDoxygen option --- jenkins/jobs.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/jenkins/jobs.groovy b/jenkins/jobs.groovy index afd5e6529a..ca01c09174 100644 --- a/jenkins/jobs.groovy +++ b/jenkins/jobs.groovy @@ -148,6 +148,7 @@ doxygenJob.with { project / publishers / 'hudson.plugins.doxygen.DoxygenArchiver' { doxyfilePath 'Doxyfile' keepAll false + folderWhereYouRunDoxygen '' } } } From ab7c5eb1e67144f2c910f635336f571b84069c76 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 15 Aug 2013 17:48:27 -0700 Subject: [PATCH 10/15] comment out docs in seed for now --- jenkins/jobs.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jenkins/jobs.groovy b/jenkins/jobs.groovy index ca01c09174..8e676de606 100644 --- a/jenkins/jobs.groovy +++ b/jenkins/jobs.groovy @@ -141,16 +141,16 @@ parameterizedJob.with { } } -doxygenJob = hifiJob('docs', false) +/*doxygenJob = hifiJob('docs', false) doxygenJob.with { configure { project -> (project / builders).setValue('') project / publishers / 'hudson.plugins.doxygen.DoxygenArchiver' { doxyfilePath 'Doxyfile' keepAll false - folderWhereYouRunDoxygen '' + folderWhereYouRunDoxygen ' ' } } } -queue doxygenJob \ No newline at end of file +queue doxygenJob*/ \ No newline at end of file From 2cd83ee9a84b3ba1abd32698e287ff1239a7b45e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 16 Aug 2013 10:36:01 -0700 Subject: [PATCH 11/15] remove selective listening on git push --- jenkins/jobs.groovy | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/jenkins/jobs.groovy b/jenkins/jobs.groovy index 8e676de606..870138760b 100644 --- a/jenkins/jobs.groovy +++ b/jenkins/jobs.groovy @@ -141,16 +141,20 @@ parameterizedJob.with { } } -/*doxygenJob = hifiJob('docs', false) +doxygenJob = hifiJob('docs', false) doxygenJob.with { + scm { + git(GIT_REPO_URL, 'master') {} + } + configure { project -> (project / builders).setValue('') project / publishers / 'hudson.plugins.doxygen.DoxygenArchiver' { doxyfilePath 'Doxyfile' keepAll false - folderWhereYouRunDoxygen ' ' + folderWhereYouRunDoxygen '' } } } -queue doxygenJob*/ \ No newline at end of file +queue doxygenJob \ No newline at end of file From 1802ccdc7fe781b1078dc05401fecbe59afa8d2d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 16 Aug 2013 10:42:58 -0700 Subject: [PATCH 12/15] use shell command for doxygen instead of plugin --- jenkins/jobs.groovy | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/jenkins/jobs.groovy b/jenkins/jobs.groovy index 870138760b..24e4779fa1 100644 --- a/jenkins/jobs.groovy +++ b/jenkins/jobs.groovy @@ -149,11 +149,10 @@ doxygenJob.with { configure { project -> (project / builders).setValue('') - project / publishers / 'hudson.plugins.doxygen.DoxygenArchiver' { - doxyfilePath 'Doxyfile' - keepAll false - folderWhereYouRunDoxygen '' - } + } + + steps { + shell('doxygen') } } From c579f7061144a338c128d019b31ce81e19a8be4b Mon Sep 17 00:00:00 2001 From: LionTurtle Date: Fri, 16 Aug 2013 11:44:23 -0700 Subject: [PATCH 13/15] Render lookatIndicator for cursor select even when gyros are on for more consistent behavior. --- interface/src/Application.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c4739c044d..633f35b632 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2612,17 +2612,20 @@ void Application::updateAvatar(float deltaTime) { _headMouseY = min(_headMouseY, _glWidget->height()); const float MIDPOINT_OF_SCREEN = 0.5; - - // Set lookAtPosition if an avatar is at the center of the screen - glm::vec3 screenCenterRayOrigin, screenCenterRayDirection; - _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); - - glm::vec3 eyePosition; - _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition); - if (_isLookingAtOtherAvatar) { - glm::vec3 myLookAtFromMouse(eyePosition); - _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); + // Only use gyro to set lookAt if mouse hasn't selected an avatar + if (!_isLookingAtOtherAvatar) { + + // Set lookAtPosition if an avatar is at the center of the screen + glm::vec3 screenCenterRayOrigin, screenCenterRayDirection; + _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); + + glm::vec3 eyePosition; + _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition); + if (_isLookingAtOtherAvatar) { + glm::vec3 myLookAtFromMouse(eyePosition); + _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); + } } } @@ -3027,6 +3030,7 @@ void Application::displaySide(Camera& whichCamera) { if (!avatar->isInitialized()) { avatar->init(); } + // Set lookAt to myCamera on client side if other avatars are looking at client if (isLookingAtMyAvatar(avatar)) { avatar->getHead().setLookAtPosition(_myCamera.getPosition()); } From 4d9075f21c871827e0a9b7512262000c3e7dd8f6 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 16 Aug 2013 13:58:22 -0700 Subject: [PATCH 14/15] optionally check /usr/local/lib for plugins --- interface/CMakeLists.txt | 13 ++++++------- interface/src/main.cpp | 7 +++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 17967c5f42..babbff7289 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -45,6 +45,12 @@ endforeach(SUBDIR) # project subdirectories add_subdirectory(src/starfield) +find_package(Qt5Core REQUIRED) +find_package(Qt5Gui REQUIRED) +find_package(Qt5Network REQUIRED) +find_package(Qt5OpenGL REQUIRED) +find_package(Qt5Svg REQUIRED) + if (APPLE) # set how the icon shows up in the Info.plist file SET(MACOSX_BUNDLE_ICON_FILE interface.icns) @@ -64,15 +70,8 @@ if (APPLE) SET(INTERFACE_SRCS ${INTERFACE_SRCS} ${DIR_CONTENTS}) endif() endforeach() - endif (APPLE) -find_package(Qt5Core REQUIRED) -find_package(Qt5Gui REQUIRED) -find_package(Qt5Network REQUIRED) -find_package(Qt5OpenGL REQUIRED) -find_package(Qt5Svg REQUIRED) - set(QUAZIP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/quazip) add_subdirectory(external/fervor/) include_directories(external/fervor/) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 98ed4fb231..c1d9bd778d 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -18,12 +18,19 @@ #include "Application.h" #include +#include int main(int argc, const char * argv[]) { timeval startup_time; gettimeofday(&startup_time, NULL); + #if defined(Q_OS_MAC) + const QString QT_RELEASE_PLUGIN_PATH = "/usr/local/lib/qt5/plugins"; + QCoreApplication::addLibraryPath(QT_RELEASE_PLUGIN_PATH); + #endif + Application app(argc, const_cast(argv), startup_time); + qDebug( "Created QT Application.\n" ); int exitCode = app.exec(); qDebug("Normal exit.\n"); From ed48f8d982d4e12e62b5350b0e30d7c0d1887ddc Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 16 Aug 2013 14:28:22 -0700 Subject: [PATCH 15/15] add a DISABLE_OPENNI option for release builds without OpenNI --- interface/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index babbff7289..2adc7e6643 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -100,12 +100,12 @@ find_package(UVCCameraControl) find_package(ZLIB) # let the source know that we have OpenNI/NITE for Kinect -if (OPENNI_FOUND) +if (OPENNI_FOUND AND NOT DISABLE_OPENNI) add_definitions(-DHAVE_OPENNI) include_directories(SYSTEM ${OPENNI_INCLUDE_DIRS}) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${OPENNI_INCLUDE_DIRS}") target_link_libraries(${TARGET_NAME} ${OPENNI_LIBRARIES}) -endif (OPENNI_FOUND) +endif (OPENNI_FOUND AND NOT DISABLE_OPENNI) qt5_use_modules(${TARGET_NAME} Core Gui Network OpenGL Svg)