From f04fc1592a4186d3eb7de18b9d326ac49caeffe3 Mon Sep 17 00:00:00 2001 From: Benlitz Date: Sat, 17 Apr 2021 10:07:33 +0900 Subject: [PATCH] Fix depth camera breaking shadows (#2907) * Remove modifications to the shadow technique done in the DepthCamera, this is not necessary and breaks lighting for all other cameras that will render after it in the same frame * Add call to setShadowsEnabled for the normals viewport as well Co-authored-by: Steve Peters --- gazebo/rendering/DepthCamera.cc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/gazebo/rendering/DepthCamera.cc b/gazebo/rendering/DepthCamera.cc index 512a2a0a8e..ab82e14532 100644 --- a/gazebo/rendering/DepthCamera.cc +++ b/gazebo/rendering/DepthCamera.cc @@ -239,6 +239,7 @@ void DepthCamera::CreateDepthTexture(const std::string &_textureName) this->SetDepthTarget(this->depthTarget); this->depthViewport->setOverlaysEnabled(false); + this->depthViewport->setShadowsEnabled(false); this->depthViewport->setBackgroundColour( Ogre::ColourValue(Ogre::ColourValue(0, 0, 0))); @@ -282,6 +283,7 @@ void DepthCamera::CreateDepthTexture(const std::string &_textureName) this->dataPtr->pcdViewport->setBackgroundColour( Conversions::Convert(ignBG)); this->dataPtr->pcdViewport->setOverlaysEnabled(false); + this->dataPtr->pcdViewport->setShadowsEnabled(false); this->dataPtr->pcdViewport->setVisibilityMask( GZ_VISIBILITY_ALL & ~(GZ_VISIBILITY_GUI | GZ_VISIBILITY_SELECTABLE)); @@ -378,6 +380,7 @@ void DepthCamera::CreateNormalsTexture(const std::string &_textureName) this->dataPtr->normalsViewport->setBackgroundColour( Conversions::Convert(ignBG)); this->dataPtr->normalsViewport->setOverlaysEnabled(false); + this->dataPtr->normalsViewport->setShadowsEnabled(false); this->dataPtr->normalsViewport->setVisibilityMask( GZ_VISIBILITY_ALL & ~(GZ_VISIBILITY_GUI | GZ_VISIBILITY_SELECTABLE)); @@ -602,9 +605,6 @@ void DepthCamera::RenderImpl() { Ogre::SceneManager *sceneMgr = this->scene->OgreSceneManager(); - Ogre::ShadowTechnique shadowTech = sceneMgr->getShadowTechnique(); - - sceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_NONE); sceneMgr->_suppressRenderStateChanges(true); this->UpdateRenderTarget(this->depthTarget, @@ -614,14 +614,12 @@ void DepthCamera::RenderImpl() this->depthTarget->update(false); sceneMgr->_suppressRenderStateChanges(false); - sceneMgr->setShadowTechnique(shadowTech); // for camera image Camera::RenderImpl(); if (this->dataPtr->outputPoints) { - sceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_NONE); sceneMgr->_suppressRenderStateChanges(true); this->UpdateRenderTarget(this->dataPtr->pcdTarget, @@ -630,7 +628,6 @@ void DepthCamera::RenderImpl() this->dataPtr->pcdTarget->update(false); sceneMgr->_suppressRenderStateChanges(false); - sceneMgr->setShadowTechnique(shadowTech); } if (this->dataPtr->outputReflectance) @@ -640,7 +637,6 @@ void DepthCamera::RenderImpl() if (this->dataPtr->outputNormals) { - sceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_NONE); sceneMgr->_suppressRenderStateChanges(true); this->UpdateRenderTarget(this->dataPtr->normalsTarget, @@ -649,7 +645,6 @@ void DepthCamera::RenderImpl() this->dataPtr->normalsTarget->update(false); sceneMgr->_suppressRenderStateChanges(false); - sceneMgr->setShadowTechnique(shadowTech); } }