From 451e34e46622ab7a8f6aa4d521ba0a1565b8fdb7 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Wed, 1 Nov 2023 11:38:20 -0700 Subject: [PATCH 1/9] Update examples to use metal as default graphics API on mac (#937) * Use metal as default on apple, fix compile warning, remove optix * Add defaultGraphicsAPI utility function --------- Signed-off-by: Ian Chen --- examples/actor_animation/Main.cc | 2 +- examples/boundingbox_camera/Main.cc | 18 +++++++- examples/camera_tracking/Main.cc | 3 +- .../custom_scene_viewer/ManualSceneDemo.cc | 2 +- examples/custom_shaders_uniforms/Main.cc | 2 +- examples/depth_camera/Main.cc | 4 +- examples/heightmap/Main.cc | 2 +- examples/lidar_visual/Main.cc | 2 +- examples/mesh_viewer/Main.cc | 3 +- examples/mouse_picking/Main.cc | 3 +- examples/ogre2_demo/Main.cc | 2 +- examples/particles_demo/Main.cc | 2 +- examples/projector/Main.cc | 3 +- examples/render_pass/Main.cc | 3 +- examples/segmentation_camera/Main.cc | 2 +- examples/simple_demo/Main.cc | 3 +- examples/simple_demo_qml/ThreadRenderer.cpp | 46 ++++++++++++++++--- examples/text_geom/Main.cc | 1 - examples/thermal_camera/Main.cc | 2 +- examples/transform_control/Main.cc | 3 +- examples/view_control/Main.cc | 3 +- examples/visualization_demo/Main.cc | 3 +- examples/waves/Main.cc | 2 +- examples/wide_angle_camera/Main.cc | 21 +++++++-- include/gz/rendering/Utils.hh | 7 +++ src/Utils.cc | 13 +++++- 26 files changed, 112 insertions(+), 45 deletions(-) diff --git a/examples/actor_animation/Main.cc b/examples/actor_animation/Main.cc index 70a3546fa..42d54a658 100644 --- a/examples/actor_animation/Main.cc +++ b/examples/actor_animation/Main.cc @@ -188,7 +188,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); diff --git a/examples/boundingbox_camera/Main.cc b/examples/boundingbox_camera/Main.cc index b19815bec..1cf00c590 100644 --- a/examples/boundingbox_camera/Main.cc +++ b/examples/boundingbox_camera/Main.cc @@ -217,10 +217,11 @@ void buildScene(ScenePtr _scene, BoundingBoxType _type) ////////////////////////////////////////////////// std::vector createCameras(const std::string &_engineName, + const std::map& _params, BoundingBoxType _type) { // create and populate scene - RenderEngine *engine = rendering::engine(_engineName); + RenderEngine *engine = rendering::engine(_engineName, _params); if (!engine) { gzwarn << "Engine '" << _engineName @@ -271,6 +272,12 @@ int main(int _argc, char** _argv) } } + GraphicsAPI graphicsApi = defaultGraphicsAPI(); + if (_argc > 2) + { + graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); + } + common::Console::SetVerbosity(4); std::vector engineNames; std::vector cameras; @@ -281,7 +288,14 @@ int main(int _argc, char** _argv) { try { - cameras = createCameras(engineName, bboxType); + std::map params; + if (engineName.compare("ogre2") == 0 + && graphicsApi == GraphicsAPI::METAL) + { + params["metal"] = "1"; + } + + cameras = createCameras(engineName, params, bboxType); } catch (...) { diff --git a/examples/camera_tracking/Main.cc b/examples/camera_tracking/Main.cc index 398b73b31..03279a92e 100644 --- a/examples/camera_tracking/Main.cc +++ b/examples/camera_tracking/Main.cc @@ -127,7 +127,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); @@ -139,7 +139,6 @@ int main(int _argc, char** _argv) std::vector nodes; engineNames.push_back(ogreEngineName); - engineNames.push_back("optix"); for (auto engineName : engineNames) { diff --git a/examples/custom_scene_viewer/ManualSceneDemo.cc b/examples/custom_scene_viewer/ManualSceneDemo.cc index 072f698a6..5af164988 100644 --- a/examples/custom_scene_viewer/ManualSceneDemo.cc +++ b/examples/custom_scene_viewer/ManualSceneDemo.cc @@ -192,7 +192,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); diff --git a/examples/custom_shaders_uniforms/Main.cc b/examples/custom_shaders_uniforms/Main.cc index 009681621..093de95b2 100644 --- a/examples/custom_shaders_uniforms/Main.cc +++ b/examples/custom_shaders_uniforms/Main.cc @@ -167,7 +167,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); diff --git a/examples/depth_camera/Main.cc b/examples/depth_camera/Main.cc index 08bf8a8f9..ff90e5f87 100644 --- a/examples/depth_camera/Main.cc +++ b/examples/depth_camera/Main.cc @@ -115,7 +115,7 @@ void buildScene(ScenePtr _scene) camera->SetImageFormat(PixelFormat::PF_FLOAT32_RGBA); camera->SetNearClipPlane(0.15); camera->SetFarClipPlane(10.0); - camera->SetAntiAliasing(2); + camera->SetAntiAliasing(2); camera->CreateDepthTexture(); root->AddChild(camera); @@ -154,7 +154,7 @@ int main(int _argc, char** _argv) engineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); diff --git a/examples/heightmap/Main.cc b/examples/heightmap/Main.cc index 6aaf6e143..82db73326 100644 --- a/examples/heightmap/Main.cc +++ b/examples/heightmap/Main.cc @@ -324,7 +324,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2 && buildDemScene != 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); diff --git a/examples/lidar_visual/Main.cc b/examples/lidar_visual/Main.cc index 340394171..af5aebeb7 100644 --- a/examples/lidar_visual/Main.cc +++ b/examples/lidar_visual/Main.cc @@ -272,7 +272,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); diff --git a/examples/mesh_viewer/Main.cc b/examples/mesh_viewer/Main.cc index 32d9f0f51..a0c32a156 100644 --- a/examples/mesh_viewer/Main.cc +++ b/examples/mesh_viewer/Main.cc @@ -142,7 +142,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); @@ -153,7 +153,6 @@ int main(int _argc, char** _argv) std::vector cameras; engineNames.push_back(ogreEngineName); - engineNames.push_back("optix"); for (auto engineName : engineNames) { diff --git a/examples/mouse_picking/Main.cc b/examples/mouse_picking/Main.cc index 589839fc2..d94bc4d1e 100644 --- a/examples/mouse_picking/Main.cc +++ b/examples/mouse_picking/Main.cc @@ -135,7 +135,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); @@ -146,7 +146,6 @@ int main(int _argc, char** _argv) std::vector cameras; engineNames.push_back(ogreEngineName); - engineNames.push_back("optix"); for (auto engineName : engineNames) { diff --git a/examples/ogre2_demo/Main.cc b/examples/ogre2_demo/Main.cc index 337cf1d12..999b00252 100644 --- a/examples/ogre2_demo/Main.cc +++ b/examples/ogre2_demo/Main.cc @@ -317,7 +317,7 @@ int main(int _argc, char** _argv) std::vector engineNames; std::vector cameras; - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); diff --git a/examples/particles_demo/Main.cc b/examples/particles_demo/Main.cc index 03dbca5b6..9ed66c568 100644 --- a/examples/particles_demo/Main.cc +++ b/examples/particles_demo/Main.cc @@ -168,7 +168,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); diff --git a/examples/projector/Main.cc b/examples/projector/Main.cc index a991c98dd..f78224b16 100644 --- a/examples/projector/Main.cc +++ b/examples/projector/Main.cc @@ -180,7 +180,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); @@ -191,7 +191,6 @@ int main(int _argc, char** _argv) std::vector cameras; engineNames.push_back(ogreEngineName); - engineNames.push_back("optix"); for (auto engineName : engineNames) { try diff --git a/examples/render_pass/Main.cc b/examples/render_pass/Main.cc index a3a1c86bc..21863d807 100644 --- a/examples/render_pass/Main.cc +++ b/examples/render_pass/Main.cc @@ -198,7 +198,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); @@ -209,7 +209,6 @@ int main(int _argc, char** _argv) std::vector cameras; engineNames.push_back(ogreEngineName); - engineNames.push_back("optix"); for (auto engineName : engineNames) { try diff --git a/examples/segmentation_camera/Main.cc b/examples/segmentation_camera/Main.cc index 46a07f0c0..0dda4ecd7 100644 --- a/examples/segmentation_camera/Main.cc +++ b/examples/segmentation_camera/Main.cc @@ -150,7 +150,7 @@ int main(int _argc, char** _argv) engineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); diff --git a/examples/simple_demo/Main.cc b/examples/simple_demo/Main.cc index 3a32e1391..1ea6e0f67 100644 --- a/examples/simple_demo/Main.cc +++ b/examples/simple_demo/Main.cc @@ -218,7 +218,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); @@ -229,7 +229,6 @@ int main(int _argc, char** _argv) std::vector cameras; engineNames.push_back(ogreEngineName); - engineNames.push_back("optix"); for (auto engineName : engineNames) { diff --git a/examples/simple_demo_qml/ThreadRenderer.cpp b/examples/simple_demo_qml/ThreadRenderer.cpp index 91731ef5f..4aff4dee6 100644 --- a/examples/simple_demo_qml/ThreadRenderer.cpp +++ b/examples/simple_demo_qml/ThreadRenderer.cpp @@ -129,7 +129,7 @@ void RenderThread::Print(const QSurfaceFormat &_format) return "CompatibilityProfile"; default: return "Invalid OpenGLContextProfile"; - } + } }; auto renderableTypeToString = [] (QSurfaceFormat::RenderableType _value) -> std::string @@ -146,7 +146,7 @@ void RenderThread::Print(const QSurfaceFormat &_format) return "OpenVG"; default: return "Invalid RenderableType"; - } + } }; auto swapBehaviorToString = [] (QSurfaceFormat::SwapBehavior _value) -> std::string @@ -161,7 +161,7 @@ void RenderThread::Print(const QSurfaceFormat &_format) return "DoubleBuffer"; default: return "Invalid SwapBehavior"; - } + } }; // surface format info @@ -200,7 +200,7 @@ QSurfaceFormat RenderThread::CreateSurfaceFormat() format.setProfile(QSurfaceFormat::CoreProfile); format.setRenderableType(QSurfaceFormat::OpenGL); - return format; + return format; } //-------------------------------------------------------------------------- @@ -272,8 +272,25 @@ TextureNode::TextureNode(QQuickWindow *_window) , window(_window) { // Our texture node must have a texture, so use the default 0 texture. - // createTextureFromNativeObject() +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) +# ifndef _WIN32 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +# endif this->texture = this->window->createTextureFromId(0, QSize(1, 1)); +# ifndef _WIN32 +# pragma GCC diagnostic pop +# endif +#else + int texId = 0; + this->texture = + this->window->createTextureFromNativeObject( + QQuickWindow::NativeObjectTexture, + static_cast(&texId), + 0, + QSize(1, 1)); +#endif + this->setTexture(this->texture); this->setFiltering(QSGTexture::Linear); } @@ -314,8 +331,23 @@ void TextureNode::PrepareNode() this->texture = nullptr; // note: include QQuickWindow::TextureHasAlphaChannel if the rendered content // has alpha. - // createTextureFromNativeObject +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) +# ifndef _WIN32 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +# endif this->texture = this->window->createTextureFromId(newId, size); +# ifndef _WIN32 +# pragma GCC diagnostic pop +# endif +#else + this->texture = + this->window->createTextureFromNativeObject( + QQuickWindow::NativeObjectTexture, + static_cast(&newId), + 0, + size); +#endif this->setTexture(this->texture); this->markDirty(DirtyMaterial); @@ -342,7 +374,7 @@ void ThreadRenderer::Ready() this->renderThread->surface->setFormat(this->renderThread->context->format()); this->renderThread->surface->create(); - // carry out any initialisation before moving to thread + // carry out any initialisation before moving to thread this->renderThread->InitialiseOnMainThread(); // Move to Render thread diff --git a/examples/text_geom/Main.cc b/examples/text_geom/Main.cc index 26033be35..7149d1df0 100644 --- a/examples/text_geom/Main.cc +++ b/examples/text_geom/Main.cc @@ -126,7 +126,6 @@ int main(int _argc, char** _argv) std::vector cameras; engineNames.push_back("ogre"); - engineNames.push_back("optix"); for (auto engineName : engineNames) { try diff --git a/examples/thermal_camera/Main.cc b/examples/thermal_camera/Main.cc index 5e7fe2701..68157a0c9 100644 --- a/examples/thermal_camera/Main.cc +++ b/examples/thermal_camera/Main.cc @@ -138,7 +138,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); diff --git a/examples/transform_control/Main.cc b/examples/transform_control/Main.cc index 79a0b8e7e..22dec4d3b 100644 --- a/examples/transform_control/Main.cc +++ b/examples/transform_control/Main.cc @@ -121,7 +121,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); @@ -132,7 +132,6 @@ int main(int _argc, char** _argv) std::vector cameras; engineNames.push_back(ogreEngineName); - engineNames.push_back("optix"); for (auto engineName : engineNames) { diff --git a/examples/view_control/Main.cc b/examples/view_control/Main.cc index a501e3cff..5d12fc365 100644 --- a/examples/view_control/Main.cc +++ b/examples/view_control/Main.cc @@ -167,7 +167,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); @@ -178,7 +178,6 @@ int main(int _argc, char** _argv) std::vector cameras; engineNames.push_back(ogreEngineName); - engineNames.push_back("optix"); for (auto engineName : engineNames) { try diff --git a/examples/visualization_demo/Main.cc b/examples/visualization_demo/Main.cc index 23ace7294..104ef4250 100644 --- a/examples/visualization_demo/Main.cc +++ b/examples/visualization_demo/Main.cc @@ -248,7 +248,7 @@ int main(int _argc, char** _argv) engine = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); @@ -259,7 +259,6 @@ int main(int _argc, char** _argv) std::vector cameras; engineNames.push_back(engine); - engineNames.push_back("optix"); for (auto engineName : engineNames) { diff --git a/examples/waves/Main.cc b/examples/waves/Main.cc index 14d04e39a..44889751e 100644 --- a/examples/waves/Main.cc +++ b/examples/waves/Main.cc @@ -164,7 +164,7 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } - GraphicsAPI graphicsApi = GraphicsAPI::OPENGL; + GraphicsAPI graphicsApi = defaultGraphicsAPI(); if (_argc > 2) { graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); diff --git a/examples/wide_angle_camera/Main.cc b/examples/wide_angle_camera/Main.cc index 02da36123..63d6d7073 100644 --- a/examples/wide_angle_camera/Main.cc +++ b/examples/wide_angle_camera/Main.cc @@ -137,10 +137,11 @@ void buildScene(ScenePtr _scene) } ////////////////////////////////////////////////// -CameraPtr createCamera(const std::string &_engineName) +CameraPtr createCamera(const std::string &_engineName, + const std::map& _params) { // create and populate scene - RenderEngine *engine = rendering::engine(_engineName); + RenderEngine *engine = rendering::engine(_engineName, _params); if (!engine) { gzwarn << "Engine '" << _engineName @@ -168,18 +169,30 @@ int main(int _argc, char** _argv) ogreEngineName = _argv[1]; } + GraphicsAPI graphicsApi = defaultGraphicsAPI(); + if (_argc > 2) + { + graphicsApi = GraphicsAPIUtils::Set(std::string(_argv[2])); + } + common::Console::SetVerbosity(4); std::vector engineNames; std::vector cameras; engineNames.push_back(ogreEngineName); - engineNames.push_back("optix"); for (auto engineName : engineNames) { try { - CameraPtr camera = createCamera(engineName); + std::map params; + if (engineName.compare("ogre2") == 0 + && graphicsApi == GraphicsAPI::METAL) + { + params["metal"] = "1"; + } + + CameraPtr camera = createCamera(engineName, params); if (camera) { cameras.push_back(camera); diff --git a/include/gz/rendering/Utils.hh b/include/gz/rendering/Utils.hh index 4d53fe2c9..65a50b820 100644 --- a/include/gz/rendering/Utils.hh +++ b/include/gz/rendering/Utils.hh @@ -29,6 +29,7 @@ #include "gz/rendering/Camera.hh" #include "gz/rendering/config.hh" #include "gz/rendering/Export.hh" +#include "gz/rendering/GraphicsAPI.hh" #include "gz/rendering/RayQuery.hh" #include "gz/rendering/Image.hh" @@ -120,6 +121,12 @@ namespace gz /// \return Image in bayer format GZ_RENDERING_VISIBLE Image convertRGBToBayer(const Image &_image, PixelFormat _bayerFormat); + + /// \brief Convenience function to get the default graphics API based on + /// current platform + /// \return Graphics API, i.e. METAL, OPENGL, VULKAN + GZ_RENDERING_VISIBLE + GraphicsAPI defaultGraphicsAPI(); } } } diff --git a/src/Utils.cc b/src/Utils.cc index f6ddcf396..a5ff03ea8 100644 --- a/src/Utils.cc +++ b/src/Utils.cc @@ -25,8 +25,9 @@ #include "gz/math/Vector3.hh" #include "gz/rendering/Camera.hh" -#include "gz/rendering/RayQuery.hh" +#include "gz/rendering/GraphicsAPI.hh" #include "gz/rendering/PixelFormat.hh" +#include "gz/rendering/RayQuery.hh" #include "gz/rendering/Utils.hh" @@ -393,6 +394,16 @@ Image convertRGBToBayer(const Image &_image, PixelFormat _bayerFormat) return destImage; } +///////////////////////////////////////////////// +GraphicsAPI defaultGraphicsAPI() +{ +#ifdef __APPLE__ + return GraphicsAPI::METAL; +#else + return GraphicsAPI::OPENGL; +#endif +} + } } } From 303e843ff062ab624a28b9036fd74ad111df4b44 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Mon, 4 Dec 2023 21:05:38 +0000 Subject: [PATCH 2/9] Set projector emissive texture (#946) Set projector emissive texture to be the same as the diffuse texture in ogre 2.x implementation for a more consistent result with the ogre 1.x implementation Signed-off-by: Ian Chen --- ogre2/src/Ogre2Projector.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ogre2/src/Ogre2Projector.cc b/ogre2/src/Ogre2Projector.cc index ef68310de..3ca9eb4a8 100644 --- a/ogre2/src/Ogre2Projector.cc +++ b/ogre2/src/Ogre2Projector.cc @@ -168,6 +168,8 @@ void Ogre2Projector::UpdateCameraListener() this->dataPtr->decalNode->setVisible(true); this->dataPtr->decalNode->getCreator()->setDecalsDiffuse( this->dataPtr->decal->getDiffuseTexture()); + this->dataPtr->decalNode->getCreator()->setDecalsEmissive( + this->dataPtr->decal->getEmissiveTexture()); for (auto &ogreCamIt : this->dataPtr->camerasWithListener) { @@ -276,6 +278,7 @@ void Ogre2Projector::CreateProjector() Ogre::GpuResidency::Resident); this->dataPtr->decal->setDiffuseTexture(this->dataPtr->textureDiff); + this->dataPtr->decal->setEmissiveTexture(this->dataPtr->textureDiff); // approximate frustum size common::Image image(this->textureName); @@ -332,6 +335,8 @@ void Ogre2ProjectorCameraListener::cameraPreRenderScene( this->decalNode->setVisible(true); this->decalNode->getCreator()->setDecalsDiffuse( this->decal->getDiffuseTexture()); + this->decalNode->getCreator()->setDecalsEmissive( + this->decal->getEmissiveTexture()); } } From 0af16529da843cf9770dd6f199854c79e6047f35 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Wed, 20 Dec 2023 12:14:41 -0800 Subject: [PATCH 3/9] update readme badge (#947) Signed-off-by: Ian Chen --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 65d93b082..57f0b7f5b 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ Build | Status -- | -- Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-rendering/branch/main/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-rendering/branch/default) Ubuntu Jammy | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-main-jammy-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-main-jammy-amd64) -Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_rendering-ci-main-homebrew-amd64)](https://build.osrfoundation.org/job/ignition_rendering-ci-main-homebrew-amd64) -Windows | [![Build Status](https://build.osrfoundation.org/job/ign_rendering-ci-win/badge/icon)](https://build.osrfoundation.org/job/ign_rendering-ci-win/) +Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-main-homebrew-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-main-homebrew-amd64) +Windows | [![Build Status](https://build.osrfoundation.org/job/gz_rendering-main-win/badge/icon)](https://build.osrfoundation.org/job/gz_rendering-main-win/) Gazebo Rendering is a C++ library designed to provide an abstraction for different rendering engines. It offers unified APIs for creating From 93c278546da2152653f01187a910a1a0b97d7373 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Thu, 21 Dec 2023 07:37:52 -0800 Subject: [PATCH 4/9] Update CI badges to point to release branch job (#948) Signed-off-by: Ian Chen --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 57f0b7f5b..0a0666c17 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ Build | Status -- | -- -Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-rendering/branch/main/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-rendering/branch/default) -Ubuntu Jammy | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-main-jammy-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-main-jammy-amd64) -Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-main-homebrew-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-main-homebrew-amd64) -Windows | [![Build Status](https://build.osrfoundation.org/job/gz_rendering-main-win/badge/icon)](https://build.osrfoundation.org/job/gz_rendering-main-win/) +Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-rendering/tree/gz-rendering8/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-rendering/tree/gz-rendering8) +Ubuntu Jammy | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-gz-rendering8-jammy-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-gz-rendering8-jammy-amd64) +Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-gz-rendering8-homebrew-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-gz-rendering8-homebrew-amd64) +Windows | [![Build Status](https://build.osrfoundation.org/job/gz_rendering-8-win/badge/icon)](https://build.osrfoundation.org/job/gz_rendering-8-win/) Gazebo Rendering is a C++ library designed to provide an abstraction for different rendering engines. It offers unified APIs for creating From 5cad5c0fb5890c899118fcb3551065d99d6827d1 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Tue, 2 Jan 2024 15:17:45 -0800 Subject: [PATCH 5/9] Remove todo in gpu ray test (#949) Remove code as mentioned in the todo note now that the OgreHeightmap::Destroy function is available. The test should not crash. Signed-off-by: Ian Chen --- test/integration/gpu_rays.cc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/integration/gpu_rays.cc b/test/integration/gpu_rays.cc index 2e5c79133..63413af51 100644 --- a/test/integration/gpu_rays.cc +++ b/test/integration/gpu_rays.cc @@ -1024,14 +1024,6 @@ TEST_F(GpuRaysTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Heightmap)) delete [] scan; scan = nullptr; - // \todo(iche033) Implement Ogre2Heightmap::Destroy function in gz-rendering8 - // this should not be needed once Ogre2Heightmap::Destroy is implemented. - if (engine->Name() == "ogre2") - { - vis->Destroy(); - heightmap.reset(); - } - // Clean up engine->DestroyScene(scene); } From d323506a29be0f3c60293be64d5154ea818bf08c Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Thu, 4 Jan 2024 10:04:40 -0600 Subject: [PATCH 6/9] Correctly set position-independent code (#950) This was broken by https://github.com/gazebosim/gz-cmake/pull/399, since we dropped the gazebo-specific flag, we can use native CMake mechanism for marking this library position-independent. Signed-off-by: Michael Carroll --- ogre2/src/terrain/Terra/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ogre2/src/terrain/Terra/CMakeLists.txt b/ogre2/src/terrain/Terra/CMakeLists.txt index c4686fadf..3da281652 100644 --- a/ogre2/src/terrain/Terra/CMakeLists.txt +++ b/ogre2/src/terrain/Terra/CMakeLists.txt @@ -7,10 +7,8 @@ file( GLOB_RECURSE TERRA_SOURCES ) add_library(${PROJECT_NAME} STATIC ${TERRA_SOURCES}) +set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON) -if(GZ_ADD_fPIC_TO_LIBRARIES AND NOT _gz_add_library_INTERFACE) - target_compile_options(${PROJECT_NAME} PRIVATE -fPIC) -endif() # disable all warnings for Terra if (UNIX) From c62f6e91940b30af6f2dcc7accafb828131e2050 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Tue, 16 Jan 2024 17:45:32 -0800 Subject: [PATCH 7/9] Improve Ogre2GpuRays performance (#955) * improve ogre2 gpu rays perf --------- Signed-off-by: Ian Chen --- ogre2/src/media/materials/scripts/GpuRays.compositor | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ogre2/src/media/materials/scripts/GpuRays.compositor b/ogre2/src/media/materials/scripts/GpuRays.compositor index da6305118..c3d2417e0 100644 --- a/ogre2/src/media/materials/scripts/GpuRays.compositor +++ b/ogre2/src/media/materials/scripts/GpuRays.compositor @@ -33,9 +33,12 @@ compositor_node GpuRays1stPass // kLaserRetroMainDepthPassId identifier 9525 - // IGN_VISIBILITY_ALL & ~Ogre2ParticleEmitter::kParticleVisibilityFlags + // GZ_VISIBILITY_ALL & ~Ogre2ParticleEmitter::kParticleVisibilityFlags visibility_mask 0xFEFFFFF + enable_forwardplus no + light_visibility_mask 0x0 + profiling_id "GpuRays1stPass Color" } } @@ -53,6 +56,9 @@ compositor_node GpuRays1stPass // Ogre2ParticleEmitter::kParticleVisibilityFlags visibility_mask 0x00100000 + enable_forwardplus no + light_visibility_mask 0x0 + profiling_id "GpuRays1stPass Particle" } } From 7116f01bd5e015cbfc245e55641d8b5fed99f586 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Mon, 22 Jan 2024 10:04:21 -0800 Subject: [PATCH 8/9] Fix repeatedly loading engine when calling sceneFromFirstEngine (#961) Signed-off-by: Ian Chen --- src/RenderEngineManager.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/RenderEngineManager.cc b/src/RenderEngineManager.cc index 8a213121d..505e1d90a 100644 --- a/src/RenderEngineManager.cc +++ b/src/RenderEngineManager.cc @@ -378,11 +378,18 @@ RenderEngine *RenderEngineManagerPrivate::Engine(EngineInfo _info, if (defaultIt != this->defaultEngines.end()) libName = defaultIt->second; - // Load the engine plugin - if (this->LoadEnginePlugin(libName, _path)) + std::lock_guard lock(this->enginesMutex); + // Check to see if we need to load the engine + auto engineIt = this->engines.find(libName); + // Engine is already loaded + if (engineIt != this->engines.end() && engineIt->second) + { + engine = engineIt->second; + } + // Load the engine + else if (this->LoadEnginePlugin(libName, _path)) { - std::lock_guard lock(this->enginesMutex); - auto engineIt = this->engines.find(libName); + engineIt = this->engines.find(libName); if (engineIt != this->engines.end()) engine = engineIt->second; } From e77e0444ba094ffd49629c5a3958c2f019018cbe Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 23 Jan 2024 15:07:15 +0000 Subject: [PATCH 9/9] Update readme for main Signed-off-by: Michael Carroll --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 550edfce7..218c13502 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ Build | Status -- | -- -Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-rendering/tree/gz-rendering8/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-rendering/tree/gz-rendering8) -Ubuntu Jammy | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-gz-rendering8-jammy-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-gz-rendering8-jammy-amd64) -Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-gz-rendering8-homebrew-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-gz-rendering8-homebrew-amd64) -Windows | [![Build Status](https://build.osrfoundation.org/job/gz_rendering-8-win/badge/icon)](https://build.osrfoundation.org/job/gz_rendering-8-win/) +Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-rendering/tree/main/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-rendering/tree/main) +Ubuntu Jammy | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-main-jammy-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-main-jammy-amd64) +Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-main-homebrew-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-main-homebrew-amd64) +Windows | [![Build Status](https://build.osrfoundation.org/job/gz_rendering-main-win/badge/icon)](https://build.osrfoundation.org/job/gz_rendering-main-win/) Gazebo Rendering is a C++ library designed to provide an abstraction for different rendering engines. It offers unified APIs for creating