From dd8b465384315eb8ed198446c8aeeb37ded60125 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Fri, 4 Mar 2022 16:52:50 -0800 Subject: [PATCH 1/4] Fix objects using shaders when there is a lidar in the scene (ogre2) (#575) * fix shaders when there is lidar in the scene Signed-off-by: Ian Chen * style Signed-off-by: Ian Chen --- ogre2/src/Ogre2GpuRays.cc | 35 +++++++++++++++++++++++++----- ogre2/src/Ogre2MaterialSwitcher.cc | 15 +++++++++++-- test/integration/camera.cc | 21 ++++++++++++++++++ 3 files changed, 64 insertions(+), 7 deletions(-) diff --git a/ogre2/src/Ogre2GpuRays.cc b/ogre2/src/Ogre2GpuRays.cc index 0cb21195a..1821b121b 100644 --- a/ogre2/src/Ogre2GpuRays.cc +++ b/ogre2/src/Ogre2GpuRays.cc @@ -198,6 +198,11 @@ class ignition::rendering::Ogre2GpuRaysPrivate using namespace ignition; using namespace rendering; +/// \brief A map of ogre sub item pointer to their original low level material +/// \todo(anyone) Added here for ABI compatibity. Move to private class +/// in ign-rendering7 +std::map> laserRetroMaterialMap; ////////////////////////////////////////////////// Ogre2LaserRetroMaterialSwitcher::Ogre2LaserRetroMaterialSwitcher( @@ -230,7 +235,6 @@ void Ogre2LaserRetroMaterialSwitcher::cameraPreRenderScene( // swap item to use v1 shader material // Note: keep an eye out for performance impact on switching materials // on the fly. We are not doing this often so should be ok. - this->datablockMap.clear(); auto itor = this->scene->OgreSceneManager()->getMovableObjectIterator( Ogre::ItemFactory::FACTORY_TYPE_NAME); while (itor.hasMoreElements()) @@ -304,9 +308,18 @@ void Ogre2LaserRetroMaterialSwitcher::cameraPreRenderScene( subItem->setCustomParameter(this->customParamIdx, Ogre::Vector4(color, color, color, 1.0)); - Ogre::HlmsDatablock *datablock = subItem->getDatablock(); - this->datablockMap[subItem] = datablock; - + // case when item is using low level materials + // e.g. shaders + if (!subItem->getMaterial().isNull()) + { + laserRetroMaterialMap[this][subItem] = subItem->getMaterial(); + } + // regular Pbs Hlms datablock + else + { + Ogre::HlmsDatablock *datablock = subItem->getDatablock(); + this->datablockMap[subItem] = datablock; + } subItem->setMaterial(this->laserRetroSourceMaterial); } itor.moveNext(); @@ -324,12 +337,24 @@ void Ogre2LaserRetroMaterialSwitcher::cameraPostRenderScene( subItem->setDatablock(it.second); } + auto laserRetroIt = laserRetroMaterialMap.find(this); + if (laserRetroIt != laserRetroMaterialMap.end()) + { + for (auto it : laserRetroIt->second) + { + Ogre::SubItem *subItem = it.first; + subItem->setMaterial(it.second); + } + } + Ogre::Pass *pass = this->laserRetroSourceMaterial->getBestTechnique()->getPass(0u); pass->getVertexProgramParameters()->setNamedConstant( "ignMinClipDistance", 0.0f ); -} + this->datablockMap.clear(); + laserRetroMaterialMap[this].clear(); +} ////////////////////////////////////////////////// Ogre2GpuRays::Ogre2GpuRays() diff --git a/ogre2/src/Ogre2MaterialSwitcher.cc b/ogre2/src/Ogre2MaterialSwitcher.cc index 45c38e88b..905684f91 100644 --- a/ogre2/src/Ogre2MaterialSwitcher.cc +++ b/ogre2/src/Ogre2MaterialSwitcher.cc @@ -37,8 +37,8 @@ using namespace rendering; /// \brief A map of ogre sub item pointer to their original low level material -/// \todo(anyone) Added here for ABI compatibity This can be removed once -/// ign-rendering7 switches to Hlms customization for "switching" materials +/// \todo(anyone) Added here for ABI compatibity. Move to private class +/// in ign-rendering7 std::map> materialMap; @@ -110,6 +110,17 @@ void Ogre2MaterialSwitcher::cameraPreRenderScene( { materialMap[this][subItem] = subItem->getMaterial(); subItem->setMaterial(this->plainMaterial); + auto technique = subItem->getMaterial()->getTechnique(0); + + if (technique && !technique->isDepthWriteEnabled() && + !technique->isDepthCheckEnabled()) + { + subItem->setMaterial(this->plainOverlayMaterial); + } + else + { + subItem->setMaterial(this->plainMaterial); + } } // regular Pbs Hlms datablock else diff --git a/test/integration/camera.cc b/test/integration/camera.cc index 92fd0f252..8c14beaf5 100644 --- a/test/integration/camera.cc +++ b/test/integration/camera.cc @@ -22,6 +22,7 @@ #include "test_config.h" // NOLINT(build/include) #include "ignition/rendering/Camera.hh" +#include "ignition/rendering/GpuRays.hh" #include "ignition/rendering/RenderEngine.hh" #include "ignition/rendering/RenderingIface.hh" #include "ignition/rendering/Scene.hh" @@ -663,6 +664,25 @@ void CameraTest::ShaderSelection(const std::string &_renderEngine) camera->SetHFOV(IGN_PI / 2); root->AddChild(camera); + // Create a gpu ray + // laser retro material switching may also affect shader materials + const double hMinAngle = -IGN_PI/2.0; + const double hMaxAngle = IGN_PI/2.0; + const double minRange = 0.1; + const double maxRange = 10.0; + const int hRayCount = 320; + const int vRayCount = 1; + GpuRaysPtr gpuRays = scene->CreateGpuRays("gpu_rays"); + gpuRays->SetWorldPosition(0, 0, 0); + gpuRays->SetNearClipPlane(minRange); + gpuRays->SetFarClipPlane(maxRange); + gpuRays->SetAngleMin(hMinAngle); + gpuRays->SetAngleMax(hMaxAngle); + gpuRays->SetRayCount(hRayCount); + + gpuRays->SetVerticalRayCount(vRayCount); + root->AddChild(gpuRays); + if (_renderEngine == "ogre2") { // worldviewproj_matrix is a constant defined by ogre. @@ -681,6 +701,7 @@ void CameraTest::ShaderSelection(const std::string &_renderEngine) for (auto i = 0; i < 30; ++i) { camera->Update(); + gpuRays->Update(); } // capture a frame From bb1b1c27bd61dc23918b23f271ab86c95206376e Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Mon, 7 Mar 2022 08:26:51 -0800 Subject: [PATCH 2/4] fix render pass demo (#576) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ian Chen Co-authored-by: Alejandro Hernández Cordero --- examples/render_pass/Main.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/render_pass/Main.cc b/examples/render_pass/Main.cc index 73be55036..76498e7ad 100644 --- a/examples/render_pass/Main.cc +++ b/examples/render_pass/Main.cc @@ -160,18 +160,24 @@ CameraPtr createCamera(const std::string &_engineName, { // add gaussian noise pass RenderPassPtr pass = rpSystem->Create(); - GaussianNoisePassPtr noisePass = - std::dynamic_pointer_cast(pass); - noisePass->SetMean(0.1); - noisePass->SetStdDev(0.08); - camera->AddRenderPass(noisePass); + if (pass) + { + GaussianNoisePassPtr noisePass = + std::dynamic_pointer_cast(pass); + noisePass->SetMean(0.1); + noisePass->SetStdDev(0.08); + camera->AddRenderPass(noisePass); + } // add distortion pass pass = rpSystem->Create(); - DistortionPassPtr distortionPass = - std::dynamic_pointer_cast(pass); - distortionPass->SetK1(0.5); - camera->AddRenderPass(distortionPass); + if (pass) + { + DistortionPassPtr distortionPass = + std::dynamic_pointer_cast(pass); + distortionPass->SetK1(0.5); + camera->AddRenderPass(distortionPass); + } } //! [get render pass system] From 2016cd888f0babeb7dac0977d65da5f7ebd1d6af Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Mon, 14 Mar 2022 16:22:32 -0700 Subject: [PATCH 3/4] Fix shaders for other sensors that require material switching (ogre2) (#579) This PR fixes objects with shader material when there is a thermal camera or a segmentation camera in the scene. These sensor all perform material switching during a render update, and the shader materials should now be correctly restored. Also updated test. Signed-off-by: Ian Chen --- ogre2/src/Ogre2GpuRays.cc | 24 +++----- ogre2/src/Ogre2MaterialSwitcher.cc | 1 - .../src/Ogre2SegmentationMaterialSwitcher.cc | 49 ++++++++++++---- .../src/Ogre2SegmentationMaterialSwitcher.hh | 4 ++ ogre2/src/Ogre2ThermalCamera.cc | 56 ++++++++++++++++--- test/integration/camera.cc | 40 ++++++++++++- 6 files changed, 136 insertions(+), 38 deletions(-) diff --git a/ogre2/src/Ogre2GpuRays.cc b/ogre2/src/Ogre2GpuRays.cc index 1821b121b..b4bae0233 100644 --- a/ogre2/src/Ogre2GpuRays.cc +++ b/ogre2/src/Ogre2GpuRays.cc @@ -93,6 +93,9 @@ class Ogre2LaserRetroMaterialSwitcher : public Ogre::Camera::Listener /// \brief A map of ogre sub item pointer to their original hlms material private: std::map datablockMap; + + /// \brief A map of ogre sub item pointer to their original low level material + private: std::map laserRetroMaterialMap; }; } } @@ -198,12 +201,6 @@ class ignition::rendering::Ogre2GpuRaysPrivate using namespace ignition; using namespace rendering; -/// \brief A map of ogre sub item pointer to their original low level material -/// \todo(anyone) Added here for ABI compatibity. Move to private class -/// in ign-rendering7 -std::map> laserRetroMaterialMap; - ////////////////////////////////////////////////// Ogre2LaserRetroMaterialSwitcher::Ogre2LaserRetroMaterialSwitcher( Ogre2ScenePtr _scene) @@ -312,7 +309,7 @@ void Ogre2LaserRetroMaterialSwitcher::cameraPreRenderScene( // e.g. shaders if (!subItem->getMaterial().isNull()) { - laserRetroMaterialMap[this][subItem] = subItem->getMaterial(); + this->laserRetroMaterialMap[subItem] = subItem->getMaterial(); } // regular Pbs Hlms datablock else @@ -337,14 +334,11 @@ void Ogre2LaserRetroMaterialSwitcher::cameraPostRenderScene( subItem->setDatablock(it.second); } - auto laserRetroIt = laserRetroMaterialMap.find(this); - if (laserRetroIt != laserRetroMaterialMap.end()) + // restore item to use low level material + for (auto it : this->laserRetroMaterialMap) { - for (auto it : laserRetroIt->second) - { - Ogre::SubItem *subItem = it.first; - subItem->setMaterial(it.second); - } + Ogre::SubItem *subItem = it.first; + subItem->setMaterial(it.second); } Ogre::Pass *pass = @@ -353,7 +347,7 @@ void Ogre2LaserRetroMaterialSwitcher::cameraPostRenderScene( "ignMinClipDistance", 0.0f ); this->datablockMap.clear(); - laserRetroMaterialMap[this].clear(); + this->laserRetroMaterialMap.clear(); } ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2MaterialSwitcher.cc b/ogre2/src/Ogre2MaterialSwitcher.cc index 905684f91..516d880ec 100644 --- a/ogre2/src/Ogre2MaterialSwitcher.cc +++ b/ogre2/src/Ogre2MaterialSwitcher.cc @@ -109,7 +109,6 @@ void Ogre2MaterialSwitcher::cameraPreRenderScene( if (!subItem->getMaterial().isNull()) { materialMap[this][subItem] = subItem->getMaterial(); - subItem->setMaterial(this->plainMaterial); auto technique = subItem->getMaterial()->getTechnique(0); if (technique && !technique->isDepthWriteEnabled() && diff --git a/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc b/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc index 04e2438d1..133a07e6a 100644 --- a/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc +++ b/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc @@ -159,7 +159,6 @@ void Ogre2SegmentationMaterialSwitcher::cameraPreRenderScene( Ogre::Camera * /*_cam*/) { this->colorToLabel.clear(); - this->datablockMap.clear(); auto itor = this->scene->OgreSceneManager()->getMovableObjectIterator( Ogre::ItemFactory::FACTORY_TYPE_NAME); @@ -295,21 +294,41 @@ void Ogre2SegmentationMaterialSwitcher::cameraPreRenderScene( for (unsigned int i = 0; i < item->getNumSubItems(); ++i) { - // save subitems material Ogre::SubItem *subItem = item->getSubItem(i); - Ogre::HlmsDatablock *datablock = subItem->getDatablock(); - this->datablockMap[subItem] = datablock; - - // switch the material subItem->setCustomParameter(1, customParameter); - // check if it's an overlay material by assuming the - // depth check and depth write properties are off. - if (!datablock->getMacroblock()->mDepthWrite && - !datablock->getMacroblock()->mDepthCheck) - subItem->setMaterial(this->plainOverlayMaterial); + // save subitems material + // case when item is using low level materials + // e.g. shaders + if (!subItem->getMaterial().isNull()) + { + this->segmentationMaterialMap[subItem] = subItem->getMaterial(); + auto technique = subItem->getMaterial()->getTechnique(0); + + if (technique && !technique->isDepthWriteEnabled() && + !technique->isDepthCheckEnabled()) + { + subItem->setMaterial(this->plainOverlayMaterial); + } + else + { + subItem->setMaterial(this->plainMaterial); + } + } + // regular Pbs Hlms datablock else - subItem->setMaterial(this->plainMaterial); + { + Ogre::HlmsDatablock *datablock = subItem->getDatablock(); + this->datablockMap[subItem] = datablock; + + // check if it's an overlay material by assuming the + // depth check and depth write properties are off. + if (!datablock->getMacroblock()->mDepthWrite && + !datablock->getMacroblock()->mDepthCheck) + subItem->setMaterial(this->plainOverlayMaterial); + else + subItem->setMaterial(this->plainMaterial); + } } } } @@ -340,6 +359,12 @@ void Ogre2SegmentationMaterialSwitcher::cameraPostRenderScene( for (const auto &[subItem, dataBlock] : this->datablockMap) subItem->setDatablock(dataBlock); + for (const auto &[subItem, material] : this->segmentationMaterialMap) + subItem->setMaterial(material); + + this->datablockMap.clear(); + this->segmentationMaterialMap.clear(); + // re-enable heightmaps auto heightmaps = this->scene->Heightmaps(); for (auto h : heightmaps) diff --git a/ogre2/src/Ogre2SegmentationMaterialSwitcher.hh b/ogre2/src/Ogre2SegmentationMaterialSwitcher.hh index bb78ea0b9..8cd08b87e 100644 --- a/ogre2/src/Ogre2SegmentationMaterialSwitcher.hh +++ b/ogre2/src/Ogre2SegmentationMaterialSwitcher.hh @@ -18,6 +18,7 @@ #ifndef IGNITION_RENDERING_OGRE2_OGRE2SEGMENTATIONMATERIALSWITCHER_HH_ #define IGNITION_RENDERING_OGRE2_OGRE2SEGMENTATIONMATERIALSWITCHER_HH_ +#include #include #include #include @@ -91,6 +92,9 @@ class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2SegmentationMaterialSwitcher : private: std::unordered_map datablockMap; + /// \brief A map of ogre sub item pointer to their original low level material + private: std::map segmentationMaterialMap; + /// \brief Ogre material consisting of a shader that changes the /// appearance of item to use a unique color for mouse picking private: Ogre::MaterialPtr plainMaterial; diff --git a/ogre2/src/Ogre2ThermalCamera.cc b/ogre2/src/Ogre2ThermalCamera.cc index 7b9de6495..c7aac0b2d 100644 --- a/ogre2/src/Ogre2ThermalCamera.cc +++ b/ogre2/src/Ogre2ThermalCamera.cc @@ -138,6 +138,9 @@ class Ogre2ThermalCameraMaterialSwitcher : public Ogre::Camera::Listener private: std::unordered_map datablockMap; + /// \brief A map of ogre sub item pointer to their original low level material + private: std::map thermalMaterialMap; + /// \brief linear temperature resolution. Defaults to 10mK private: double resolution = 0.01; @@ -151,7 +154,6 @@ class Ogre2ThermalCameraMaterialSwitcher : public Ogre::Camera::Listener } } - /// \internal /// \brief Private data for the Ogre2ThermalCamera class class ignition::rendering::Ogre2ThermalCameraPrivate @@ -242,7 +244,6 @@ void Ogre2ThermalCameraMaterialSwitcher::cameraPreRenderScene( // swap item to use v1 shader material // Note: keep an eye out for performance impact on switching materials // on the fly. We are not doing this often so should be ok. - this->datablockMap.clear(); auto itor = this->scene->OgreSceneManager()->getMovableObjectIterator( Ogre::ItemFactory::FACTORY_TYPE_NAME); while (itor.hasMoreElements()) @@ -319,9 +320,18 @@ void Ogre2ThermalCameraMaterialSwitcher::cameraPreRenderScene( // see media/materials/programs/thermal_camera_fs.glsl subItem->setCustomParameter(this->customParamIdx, Ogre::Vector4(color, 0, 0, 0.0)); - Ogre::HlmsDatablock *datablock = subItem->getDatablock(); - this->datablockMap[subItem] = datablock; - + // case when item is using low level materials + // e.g. shaders + if (!subItem->getMaterial().isNull()) + { + this->thermalMaterialMap[subItem] = subItem->getMaterial(); + } + // regular Pbs Hlms datablock + else + { + Ogre::HlmsDatablock *datablock = subItem->getDatablock(); + this->datablockMap[subItem] = datablock; + } subItem->setMaterial(this->heatSourceMaterial); } } @@ -384,8 +394,18 @@ void Ogre2ThermalCameraMaterialSwitcher::cameraPreRenderScene( { Ogre::SubItem *subItem = item->getSubItem(i); - Ogre::HlmsDatablock *datablock = subItem->getDatablock(); - this->datablockMap[subItem] = datablock; + // case when item is using low level materials + // e.g. shaders + if (!subItem->getMaterial().isNull()) + { + this->thermalMaterialMap[subItem] = subItem->getMaterial(); + } + // regular Pbs Hlms datablock + else + { + Ogre::HlmsDatablock *datablock = subItem->getDatablock(); + this->datablockMap[subItem] = datablock; + } subItem->setMaterial(this->heatSignatureMaterials[item->getId()]); } @@ -414,8 +434,16 @@ void Ogre2ThermalCameraMaterialSwitcher::cameraPreRenderScene( for (unsigned int i = 0; i < item->getNumSubItems(); ++i) { Ogre::SubItem *subItem = item->getSubItem(i); - Ogre::HlmsDatablock *datablock = subItem->getDatablock(); - this->datablockMap[subItem] = datablock; + if (!subItem->getMaterial().isNull()) + { + this->thermalMaterialMap[subItem] = subItem->getMaterial(); + } + // regular Pbs Hlms datablock + else + { + Ogre::HlmsDatablock *datablock = subItem->getDatablock(); + this->datablockMap[subItem] = datablock; + } subItem->setDatablock(unlit); } } @@ -436,6 +464,16 @@ void Ogre2ThermalCameraMaterialSwitcher::cameraPostRenderScene( Ogre::SubItem *subItem = it.first; subItem->setDatablock(it.second); } + + // restore item to use low level material + for (auto it : this->thermalMaterialMap) + { + Ogre::SubItem *subItem = it.first; + subItem->setMaterial(it.second); + } + + this->datablockMap.clear(); + this->thermalMaterialMap.clear(); } ////////////////////////////////////////////////// diff --git a/test/integration/camera.cc b/test/integration/camera.cc index 8c14beaf5..3ff8dc1f5 100644 --- a/test/integration/camera.cc +++ b/test/integration/camera.cc @@ -26,7 +26,10 @@ #include "ignition/rendering/RenderEngine.hh" #include "ignition/rendering/RenderingIface.hh" #include "ignition/rendering/Scene.hh" +#include "ignition/rendering/SegmentationCamera.hh" #include "ignition/rendering/ShaderParams.hh" +#include "ignition/rendering/ThermalCamera.hh" + using namespace ignition; using namespace rendering; @@ -647,6 +650,10 @@ void CameraTest::ShaderSelection(const std::string &_renderEngine) visual->SetWorldRotation(0.0, 0.0, 0.0); visual->SetMaterial(shader); root->AddChild(visual); + // for thermal camera + visual->SetUserData("temperature", 310.0f); + // for segmentation camera + visual->SetUserData("label", 1); // visual will clone and create a unique material // so destroy this one @@ -679,12 +686,40 @@ void CameraTest::ShaderSelection(const std::string &_renderEngine) gpuRays->SetAngleMin(hMinAngle); gpuRays->SetAngleMax(hMaxAngle); gpuRays->SetRayCount(hRayCount); - gpuRays->SetVerticalRayCount(vRayCount); root->AddChild(gpuRays); + // Create thermal camera + // heat map material switching may also affect shader materials + auto thermalCamera = scene->CreateThermalCamera("ThermalCamera"); + ASSERT_NE(thermalCamera, nullptr); + thermalCamera->SetAmbientTemperature(296.0f); + thermalCamera->SetAspectRatio(1.333); + thermalCamera->SetImageWidth(320); + thermalCamera->SetImageHeight(240); + thermalCamera->SetHFOV(IGN_PI_2); + root->AddChild(thermalCamera); + + // Currently, only ogre2 supports segmentation cameras + SegmentationCameraPtr segmentationCamera; if (_renderEngine == "ogre2") { + // Create segmentation camera + // segmentation material switching may also affect shader materials + segmentationCamera = + scene->CreateSegmentationCamera("SegmentationCamera"); + ASSERT_NE(camera, nullptr); + segmentationCamera->SetLocalPosition(0.0, 0.0, 0.0); + segmentationCamera->SetLocalRotation(0.0, 0.0, 0.0); + segmentationCamera->SetBackgroundLabel(23); + segmentationCamera->SetSegmentationType(SegmentationType::ST_SEMANTIC); + segmentationCamera->EnableColoredMap(false); + segmentationCamera->SetAspectRatio(1.333); + segmentationCamera->SetImageWidth(320); + segmentationCamera->SetImageHeight(240); + segmentationCamera->SetHFOV(IGN_PI_2); + root->AddChild(segmentationCamera); + // worldviewproj_matrix is a constant defined by ogre. // Here we add a line to add this constant to the params. // The specified value is ignored as it will be auto bound to the @@ -702,6 +737,9 @@ void CameraTest::ShaderSelection(const std::string &_renderEngine) { camera->Update(); gpuRays->Update(); + thermalCamera->Update(); + if (segmentationCamera) + segmentationCamera->Update(); } // capture a frame From f043b4fc8aa234d95b570b6ad61db0c8592be007 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Mon, 21 Mar 2022 13:56:52 -0700 Subject: [PATCH 4/4] Add Ubuntu Jammy CI (#577) * Use libogre-next-dev on jammy Specify different package names for ogre2.2 in distro-specific packages-*.apt files. * Find OGRE-Next with plain cmake Patch adapted from ignition-release/ign-rendering6-release#8 Signed-off-by: Steve Peters Co-authored-by: Louise Poubel --- .github/ci/packages-bionic.apt | 1 + .github/ci/packages-focal.apt | 1 + .github/ci/packages-jammy.apt | 1 + .github/ci/packages.apt | 1 - .github/workflows/ci.yml | 9 ++++++++ CMakeLists.txt | 21 ++++++++++++------ ogre2/src/CMakeLists.txt | 23 ++++++++++++++++++-- ogre2/src/terrain/Terra/CMakeLists.txt | 30 ++++++++++++++++++++------ 8 files changed, 71 insertions(+), 16 deletions(-) create mode 100644 .github/ci/packages-bionic.apt create mode 100644 .github/ci/packages-focal.apt create mode 100644 .github/ci/packages-jammy.apt diff --git a/.github/ci/packages-bionic.apt b/.github/ci/packages-bionic.apt new file mode 100644 index 000000000..ff9786e03 --- /dev/null +++ b/.github/ci/packages-bionic.apt @@ -0,0 +1 @@ +libogre-2.2-dev diff --git a/.github/ci/packages-focal.apt b/.github/ci/packages-focal.apt new file mode 100644 index 000000000..ff9786e03 --- /dev/null +++ b/.github/ci/packages-focal.apt @@ -0,0 +1 @@ +libogre-2.2-dev diff --git a/.github/ci/packages-jammy.apt b/.github/ci/packages-jammy.apt new file mode 100644 index 000000000..e93151b77 --- /dev/null +++ b/.github/ci/packages-jammy.apt @@ -0,0 +1 @@ +libogre-next-dev diff --git a/.github/ci/packages.apt b/.github/ci/packages.apt index 936a3194c..246461131 100644 --- a/.github/ci/packages.apt +++ b/.github/ci/packages.apt @@ -7,7 +7,6 @@ libignition-math6-dev libignition-math6-eigen3-dev libignition-plugin-dev libogre-1.9-dev -libogre-2.2-dev libxi-dev libxmu-dev uuid-dev diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53e67b817..7f4849d30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,3 +24,12 @@ jobs: - name: Compile and test id: ci uses: ignition-tooling/action-ignition-ci@focal + jammy-ci: + runs-on: ubuntu-latest + name: Ubuntu Jammy CI + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Compile and test + id: ci + uses: ignition-tooling/action-ignition-ci@jammy diff --git a/CMakeLists.txt b/CMakeLists.txt index c0b903d04..e492ff7fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,14 +96,21 @@ if (OGRE_FOUND) endif() #-------------------------------------- -# Find OGRE2 -ign_find_package(IgnOGRE2 VERSION 2.2.0 - COMPONENTS HlmsPbs HlmsUnlit Overlay - REQUIRED_BY ogre2 - PRIVATE_FOR ogre2) - -if (OGRE2_FOUND) +# Find OGRE-Next +find_package(OGRE-Next QUIET) +if (OGRE-Next_FOUND) set(HAVE_OGRE2 TRUE) + set(HAVE_OGRE-Next TRUE) +else() + # Find OGRE2 + ign_find_package(IgnOGRE2 VERSION 2.2.0 + COMPONENTS HlmsPbs HlmsUnlit Overlay + REQUIRED_BY ogre2 + PRIVATE_FOR ogre2) + + if (OGRE2_FOUND) + set(HAVE_OGRE2 TRUE) + endif() endif() # Plugin install dirs diff --git a/ogre2/src/CMakeLists.txt b/ogre2/src/CMakeLists.txt index bd3975cce..d38b0c472 100644 --- a/ogre2/src/CMakeLists.txt +++ b/ogre2/src/CMakeLists.txt @@ -27,9 +27,18 @@ set_property( OGRE2_VERSION="${OGRE2_VERSION}" ) +if (HAVE_OGRE-Next) + target_include_directories(${ogre2_target} + PUBLIC + ${OGRE-Next_INCLUDE_DIRS} + ${OGRE-Next_HlmsUnlit_INCLUDE_DIRS} + ${OGRE-Next_HlmsPbs_INCLUDE_DIRS}/../Common + ) +endif() + target_include_directories(${ogre2_target} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} ) target_link_libraries(${ogre2_target} @@ -39,7 +48,17 @@ target_link_libraries(${ogre2_target} ignition-plugin${IGN_PLUGIN_VER}::register ${OPENGL_LIBRARIES} terra - IgnOGRE2::IgnOGRE2) +) + +if (HAVE_OGRE-Next) + target_link_libraries(${ogre2_target} + PRIVATE + ${OGRE-Next_LIBRARIES}) +else() + target_link_libraries(${ogre2_target} + PRIVATE + IgnOGRE2::IgnOGRE2) +endif() set (versioned ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME_LOWER}-${engine_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) set (unversioned ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME_NO_VERSION_LOWER}-${engine_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) diff --git a/ogre2/src/terrain/Terra/CMakeLists.txt b/ogre2/src/terrain/Terra/CMakeLists.txt index 83c9ac907..31cfd6695 100644 --- a/ogre2/src/terrain/Terra/CMakeLists.txt +++ b/ogre2/src/terrain/Terra/CMakeLists.txt @@ -29,13 +29,31 @@ add_definitions(-DOGRE_IGNORE_UNKNOWN_DEBUG) # $<$:DEBUG=1 _DEBUG=1>) target_include_directories(${PROJECT_NAME} - PRIVATE - # Hlms files inside Hlms/Pbs do not have #include thus - # we must add this one manually for this to build correctly - ${OGRE2_INCLUDE}/Hlms/Pbs - ${OGRE2_INCLUDE}/Hlms/Common PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include ) -target_link_libraries(${PROJECT_NAME} PRIVATE IgnOGRE2::IgnOGRE2) +if (HAVE_OGRE-Next) + target_include_directories(${PROJECT_NAME} + PRIVATE + # Hlms files inside Hlms/Pbs do not have #include thus + # we must add this one manually for this to build correctly + ${OGRE-Next_INCLUDE_DIRS} + ${OGRE-Next_INCLUDE_DIRS}/OGRE-Next/PlanarReflections + ${OGRE-Next_HlmsPbs_INCLUDE_DIRS} + ${OGRE-Next_HlmsPbs_INCLUDE_DIRS}/.. + ${OGRE-Next_HlmsPbs_INCLUDE_DIRS}/../Common + ) + + target_link_libraries(${PROJECT_NAME} PRIVATE ${OGRE-Next_LIBRARIES}) +else() + target_include_directories(${PROJECT_NAME} + PRIVATE + # Hlms files inside Hlms/Pbs do not have #include thus + # we must add this one manually for this to build correctly + ${OGRE2_INCLUDE}/Hlms/Pbs + ${OGRE2_INCLUDE}/Hlms/Common + ) + + target_link_libraries(${PROJECT_NAME} PRIVATE IgnOGRE2::IgnOGRE2) +endif()