Skip to content

Commit

Permalink
Fix depth camera breaking shadows (#2907)
Browse files Browse the repository at this point in the history
* 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 <scpeters@openrobotics.org>
  • Loading branch information
Benlitz and scpeters committed Apr 19, 2021
1 parent 4b44af0 commit f04fc15
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions gazebo/rendering/DepthCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)));

Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -630,7 +628,6 @@ void DepthCamera::RenderImpl()
this->dataPtr->pcdTarget->update(false);

sceneMgr->_suppressRenderStateChanges(false);
sceneMgr->setShadowTechnique(shadowTech);
}

if (this->dataPtr->outputReflectance)
Expand All @@ -640,7 +637,6 @@ void DepthCamera::RenderImpl()

if (this->dataPtr->outputNormals)
{
sceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_NONE);
sceneMgr->_suppressRenderStateChanges(true);

this->UpdateRenderTarget(this->dataPtr->normalsTarget,
Expand All @@ -649,7 +645,6 @@ void DepthCamera::RenderImpl()
this->dataPtr->normalsTarget->update(false);

sceneMgr->_suppressRenderStateChanges(false);
sceneMgr->setShadowTechnique(shadowTech);
}
}

Expand Down

0 comments on commit f04fc15

Please sign in to comment.