Merge pull request #1347 from ey6es/master

Don't apply ambient occlusion to avatars (just voxels); get rid of persistence glow artifacts on startup.
This commit is contained in:
Philip Rosedale 2013-12-09 13:04:41 -08:00
commit 3d84b72e22
3 changed files with 26 additions and 16 deletions

View file

@ -2992,6 +2992,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
}
}
// render the ambient occlusion effect if enabled
if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... AmbientOcclusion...");
_ambientOcclusionEffect.render();
}
// restore default, white specular
glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);
@ -3075,13 +3082,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
renderWorldBox();
}
// render the ambient occlusion effect if enabled
if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... AmbientOcclusion...");
_ambientOcclusionEffect.render();
}
// brad's frustum for debugging
if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum) && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),

View file

@ -19,6 +19,7 @@ GlowEffect::GlowEffect()
: _initialized(false),
_renderMode(DIFFUSE_ADD_MODE),
_isOddFrame(false),
_isFirstFrame(true),
_intensity(0.0f) {
}
@ -166,16 +167,21 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
}
newDiffusedFBO->bind();
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, oldDiffusedFBO->texture());
if (_isFirstFrame) {
glClear(GL_COLOR_BUFFER_BIT);
_diffuseProgram->bind();
QSize size = Application::getInstance()->getGLWidget()->size();
_diffuseProgram->setUniformValue(_diffusionScaleLocation, 1.0f / size.width(), 1.0f / size.height());
} else {
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, oldDiffusedFBO->texture());
_diffuseProgram->bind();
QSize size = Application::getInstance()->getGLWidget()->size();
_diffuseProgram->setUniformValue(_diffusionScaleLocation, 1.0f / size.width(), 1.0f / size.height());
renderFullscreenQuad();
renderFullscreenQuad();
_diffuseProgram->release();
_diffuseProgram->release();
}
newDiffusedFBO->release();
@ -221,7 +227,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 +235,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 +276,8 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
glDepthMask(GL_TRUE);
glBindTexture(GL_TEXTURE_2D, 0);
_isFirstFrame = false;
return destFBO;
}
@ -292,6 +300,7 @@ void GlowEffect::cycleRenderMode() {
qDebug() << "Glow mode: Diffuse/add\n";
break;
}
_isFirstFrame = true;
}
Glower::Glower(float amount) {

View file

@ -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<float> _intensityStack;