Skip to content

Commit

Permalink
Fix missing terrain shadows casted on objects (#547)
Browse files Browse the repository at this point in the history
Issue was incorrect listener setup due to bad merge.

ign-rendering7 has a more robust system to handle all listeners. For
Fortress this fix will do.

Signed-off-by: Matias N. Goldberg <[email protected]>

Co-authored-by: Ian Chen <[email protected]>
  • Loading branch information
darksylinc and iche033 authored Jan 25, 2022
1 parent f305d78 commit fae20cd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
17 changes: 17 additions & 0 deletions ogre2/src/Ogre2GpuRays.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "Ogre2IgnHlmsCustomizations.hh"
#include "Ogre2ParticleNoiseListener.hh"
#include "Terra/Hlms/PbsListener/OgreHlmsPbsTerraShadows.h"

#ifdef _MSC_VER
#pragma warning(push, 0)
Expand Down Expand Up @@ -1248,12 +1249,28 @@ void Ogre2GpuRays::Render()
Ogre2IgnHlmsCustomizations &hlmsCustomizations =
engine->HlmsCustomizations();

#if IGNITION_RENDERING_MAJOR_VERSION < 7
// TODO(anyone): Remove this block of code when porting to ign-rendering7
//
// Set Ogre2IgnHlmsCustomizations, as we don't need terrain shadows
auto ogreRoot = engine->OgreRoot();
Ogre::Hlms *hlmsPbs = ogreRoot->getHlmsManager()->getHlms(Ogre::HLMS_PBS);
hlmsPbs->setListener(&hlmsCustomizations);
#endif

hlmsCustomizations.minDistanceClip =
static_cast<float>(this->NearClipPlane());
this->UpdateRenderTarget1stPass();
this->UpdateRenderTarget2ndPass();
hlmsCustomizations.minDistanceClip = -1;

#if IGNITION_RENDERING_MAJOR_VERSION < 7
// TODO(anyone): Remove this block of code when porting to ign-rendering7
//
// Restore the terrain shadows listener
hlmsPbs->setListener(engine->HlmsPbsTerraShadows());
#endif

this->scene->FlushGpuCommandsAndStartNewFrame(6u, false);
}

Expand Down
10 changes: 9 additions & 1 deletion ogre2/src/Ogre2RenderEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,15 @@ void Ogre2RenderEngine::RegisterHlms()

// disable writting debug output to disk
hlmsPbs->setDebugOutputPath(false, false);
hlmsPbs->setListener(&this->dataPtr->hlmsCustomizations);

#if IGNITION_RENDERING_MAJOR_VERSION >= 7
IGN_ASSERT(
hlmsPbs->getListener() != &this->dataPtr->hlmsCustomizations &&
hlmsPbs->getListener() != this->dataPtr->hlmsPbsTerraShadows.get(),
"Bad merge! In ign-rendering7 there's a new listener that will "
"coordinate all other listeners. Watch out all 3 Hlms (Unlit, Pbs, "
"Terra)");
#endif
}

{
Expand Down

0 comments on commit fae20cd

Please sign in to comment.