From 1cd2066e794004aa65d98e6e90c5ef80fbf81329 Mon Sep 17 00:00:00 2001 From: barnold1953 Date: Mon, 30 Jun 2014 17:13:47 -0700 Subject: [PATCH] Added option to disable glow effect for 10fps boost for oculus --- interface/src/Application.cpp | 23 +++++++++++++++++++---- interface/src/Menu.cpp | 2 ++ interface/src/Menu.h | 1 + interface/src/devices/OculusManager.cpp | 21 ++++++++++++++++----- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b29f7ed20a..fb137b6018 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -565,6 +565,8 @@ void Application::paintGL() { bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); PerformanceWarning warn(showWarnings, "Application::paintGL()"); + const bool glowEnabled = Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect); + // Set the desired FBO texture size. If it hasn't changed, this does nothing. // Otherwise, it must rebuild the FBOs if (OculusManager::isConnected()) { @@ -624,6 +626,11 @@ void Application::paintGL() { updateShadowMap(); } + //If we aren't using the glow shader, we have to clear the color and depth buffer + if (!glowEnabled) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } + if (OculusManager::isConnected()) { //When in mirror mode, use camera rotation. Otherwise, use body rotation if (whichCamera.getMode() == CAMERA_MODE_MIRROR) { @@ -633,12 +640,18 @@ void Application::paintGL() { } } else if (TV3DManager::isConnected()) { - _glowEffect.prepare(); + if (glowEnabled) { + _glowEffect.prepare(); + } TV3DManager::display(whichCamera); - _glowEffect.render(); + if (glowEnabled) { + _glowEffect.render(); + } } else { - _glowEffect.prepare(); + if (glowEnabled) { + _glowEffect.prepare(); + } glMatrixMode(GL_MODELVIEW); glPushMatrix(); @@ -646,7 +659,9 @@ void Application::paintGL() { displaySide(whichCamera); glPopMatrix(); - _glowEffect.render(); + if (glowEnabled) { + _glowEffect.render(); + } if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { renderRearViewMirror(_mirrorViewRect); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index f0decfba45..402347c5d4 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -332,6 +332,8 @@ Menu::Menu() : addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Stars, Qt::Key_Asterisk, true); addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Atmosphere, Qt::SHIFT | Qt::Key_A, true); + + addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::EnableGlowEffect, 0, true); addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::GlowMode, 0, diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 267544e0d9..a15d3712f1 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -351,6 +351,7 @@ namespace MenuOption { const QString DontFadeOnVoxelServerChanges = "Don't Fade In/Out on Voxel Server Changes"; const QString EchoLocalAudio = "Echo Local Audio"; const QString EchoServerAudio = "Echo Server Audio"; + const QString EnableGlowEffect = "Enable Glow Effect (Warning: Poor Oculus Performance)"; const QString Enable3DTVMode = "Enable 3DTV Mode"; const QString EnableVRMode = "Enable VR Mode"; const QString ExpandMiscAvatarTiming = "Expand Misc MyAvatar Timing"; diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index e9742b782f..fed0259604 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -266,8 +266,14 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p // PrioVR will only work if renderOverlay is called, calibration is connected to Application::renderingOverlay() applicationOverlay.renderOverlay(true); const bool displayOverlays = Menu::getInstance()->isOptionChecked(MenuOption::DisplayOculusOverlays); - - Application::getInstance()->getGlowEffect()->prepare(); + + //Bind our framebuffer object. If we are rendering the glow effect, we let the glow effect shader take care of it + if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) { + Application::getInstance()->getGlowEffect()->prepare(); + } else { + Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->bind(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } ovrPosef eyeRenderPose[ovrEye_Count]; @@ -332,9 +338,14 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p //Full texture viewport for glow effect glViewport(0, 0, _renderTargetSize.w, _renderTargetSize.h); - //Bind the output texture from the glow shader - QOpenGLFramebufferObject* fbo = Application::getInstance()->getGlowEffect()->render(true); - glBindTexture(GL_TEXTURE_2D, fbo->texture()); + //Bind the output texture from the glow shader. If glow effect is disabled, we just grab the texture + if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) { + QOpenGLFramebufferObject* fbo = Application::getInstance()->getGlowEffect()->render(true); + glBindTexture(GL_TEXTURE_2D, fbo->texture()); + } else { + Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->release(); + glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->texture()); + } // restore our normal viewport glViewport(0, 0, Application::getInstance()->getGLWidget()->width(), Application::getInstance()->getGLWidget()->height());