Skip to content

Commit

Permalink
From Ogre 2.1 to Ogre 2.2 (#272)
Browse files Browse the repository at this point in the history
* Ogre2.2

Signed-off-by: ahcorde <[email protected]>

* Added media files

Signed-off-by: ahcorde <[email protected]>

* Added Headless mode

Signed-off-by: ahcorde <[email protected]>

* Added feedback

Signed-off-by: ahcorde <[email protected]>

* Added feedback

Signed-off-by: ahcorde <[email protected]>

* Add OGRE2.2 to dependencies

Signed-off-by: Michael Carroll <[email protected]>

* Fixed GPUray and depthCamera test

Co-authored-by: Michael Carroll <[email protected]>

Signed-off-by: ahcorde <[email protected]>

* cast based on pf

Signed-off-by: Ian Chen <[email protected]>

* Fix cleanup with packaged debs

Signed-off-by: Michael Carroll <[email protected]>

* fix copy raw data

Signed-off-by: Ian Chen <[email protected]>

* fix material test

Signed-off-by: Ian Chen <[email protected]>

* Lint and compiler warning

Signed-off-by: Michael Carroll <[email protected]>

* Trim whitespace

Signed-off-by: Michael Carroll <[email protected]>

* Apply gamma correction to sky

Signed-off-by: ahcorde <[email protected]>

* Test fixes to Ogre2.2 branch (#279)

Signed-off-by: Michael Carroll <[email protected]>

* Revert gamma correction in the sky

Signed-off-by: ahcorde <[email protected]>

* enable grayscale albedo map to fix red color highlights and disable hardware gamma to fix dark sky color

Signed-off-by: Ian Chen <[email protected]>

* Local updates for Ogre2.2 against main branch (#317)

* Local updates for Ogre2.2 against main branch

Signed-off-by: Ian Chen <[email protected]>
Co-authored-by: Ian Chen <[email protected]>

* Fix merge

Signed-off-by: ahcorde <[email protected]>

* fix shadows in ogre 2.2

Signed-off-by: Ian Chen <[email protected]>

* Lint

Signed-off-by: Michael Carroll <[email protected]>

* fix toggling sky

Signed-off-by: Ian Chen <[email protected]>

* fix camera test

Signed-off-by: Ian Chen <[email protected]>

* make linters happy

Signed-off-by: ahcorde <[email protected]>

* make linters happy

Signed-off-by: ahcorde <[email protected]>

* Fix small regression from merge

Signed-off-by: Michael Carroll <[email protected]>

* Remove problematic leftover files from 2.1

The mere presence of these files can cause incorrect shader generation
or unknown visual bugs.

IMPORTANT: The installation folder (i.e. CMAKE_INSTALL_PREFIX) must
remove them as well.

`make install` won't be enough because it won't remove files, only add
new ones or update existing ones.

This folder is usually installed in
ign/install/share/ignition/ignition-rendering6/ogre2/media/Hlms

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

* Do not crash on shutdown

- ogreRoot may be nullptr
- Do not destroy textures already scheduled for destruction

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

* Remove problematic leftover files from 2.1 (#354)

The mere presence of these files can cause incorrect shader generation
or unknown visual bugs.

IMPORTANT: The installation folder (i.e. CMAKE_INSTALL_PREFIX) must
remove them as well.

`make install` won't be enough because it won't remove files, only add
new ones or update existing ones.

This folder is usually installed in
ign/install/share/ignition/ignition-rendering6/ogre2/media/Hlms

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

* Do not crash on shutdown (#355)

- ogreRoot may be nullptr
- Do not destroy textures already scheduled for destruction

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

* Removed unused variable

Signed-off-by: ahcorde <[email protected]>

* Restore FSAA support in 2.2 branch

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

* Fix changing background color not always taking immediate effect

Changed pass_clear in favour of LoadAction::Clear which is more
efficient on very modern GPUs and specially TBDR ones.

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

* Changed pass_clear in favour of LoadAction::Clear

which is more efficient on very modern GPUs and specially TBDR ones.

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

* Missing public keyword

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

* Save VRAM when FSAA is used and no postprocessing

There's an unused texture when these conditions are met (which are
fairly common)
This memory optimization could not be performed in Ogre 2.1, it needs
Ogre 2.2+

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

* Remove code deprecated in ign-rendering5

Syntax cosmetic changes for consistency

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

* Remove code deprecated in ign-rendering5

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

* Code style fixes

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

* Undo VRAM saving optimization: It cannot be applied

The "Final Composition" node requires both textures to be resident.
Thus 2nd texture must always be resident.

The optimization could still be applied if we create two Final
Composition nodes (one for when 2 textures are needed, another for when
only MSAA + 1 texture is needed) but this would:

  1. Hurt code readability too much (i.e. what is going on?)
  2. Increase debuggability difficulty too much because codepaths taken
would differ depending on whether optimization was applied. Also certain
bugs could remain hidden until compositors are toggled.

This was causing ogre2_demo to fail.

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

* fixing tests

Signed-off-by: Ian Chen <[email protected]>

* add ifdef

Signed-off-by: Ian Chen <[email protected]>

* suppress warnings

Signed-off-by: Ian Chen <[email protected]>

* update syntax

Signed-off-by: Ian Chen <[email protected]>

* update syntax

Signed-off-by: Ian Chen <[email protected]>

* Don't keep DEPTH_CLAMP enabled after it's used (#393)

Probably a copy-paste bug, after enabling DEPTH_CLAMP we must disable
once we're done; but we call glEnable again instead of disabling it.

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

Co-authored-by: Michael Carroll <[email protected]>
Co-authored-by: Ian Chen <[email protected]>
Co-authored-by: Matias N. Goldberg <[email protected]>
  • Loading branch information
4 people authored Sep 8, 2021
1 parent 04b2af1 commit 7def756
Show file tree
Hide file tree
Showing 128 changed files with 8,964 additions and 4,190 deletions.
2 changes: 1 addition & 1 deletion .github/ci/packages.apt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ libignition-common4-dev
libignition-math6-dev
libignition-plugin-dev
libogre-1.9-dev
libogre-2.1-dev
libogre-2.2-dev
libxi-dev
libxmu-dev
uuid-dev
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ endif()

#--------------------------------------
# Find OGRE2
ign_find_package(IgnOGRE2 VERSION 2.1.0
ign_find_package(IgnOGRE2 VERSION 2.2.0
COMPONENTS HlmsPbs HlmsUnlit Overlay
REQUIRED_BY ogre2
PRIVATE_FOR ogre2)
Expand Down
4 changes: 4 additions & 0 deletions include/ignition/rendering/Camera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ namespace ignition
/// \return Render pass at the specified index
public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index)
const = 0;

/// \internal
/// \brief Notify that shadows are dirty and need to be regenerated
public: virtual void SetShadowsDirty() = 0;
};
}
}
Expand Down
9 changes: 9 additions & 0 deletions include/ignition/rendering/RenderEngine.hh
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ namespace ignition
public: virtual ScenePtr CreateScene(unsigned int _id,
const std::string &_name) = 0;

/// \brief Set headless mode
/// Only available in OGRE 2.2, which makes use of EGL
/// \param[in] _headless Set to true to enable headless mode.
public: virtual void SetHeadless(bool _headless) = 0;

/// \brief Get headless mode
/// \return True if headless mode is enable, false otherwise.
public: virtual bool Headless() const = 0;

/// \brief Add path to media resource location
/// \param[in] _paths Absolute path to resource location
public: virtual void AddResourcePath(const std::string &_path) = 0;
Expand Down
10 changes: 10 additions & 0 deletions include/ignition/rendering/base/BaseCamera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ namespace ignition
public: virtual RenderPassPtr RenderPassByIndex(unsigned int _index)
const override;

// Documentation inherited.
public: virtual void SetShadowsDirty() override;

protected: virtual void *CreateImageBuffer() const;

protected: virtual void Load() override;
Expand Down Expand Up @@ -828,6 +831,13 @@ namespace ignition
{
return this->RenderTarget()->RenderPassByIndex(_index);
}

//////////////////////////////////////////////////
template <class T>
void BaseCamera<T>::SetShadowsDirty()
{
// no op
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions include/ignition/rendering/base/BaseRenderEngine.hh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ namespace ignition
// Documentation Inherited
public: virtual void AddResourcePath(const std::string &_path) override;

// Documentation Inherited
public: virtual void SetHeadless(bool _headless) override;

// Documentation Inherited
public: virtual bool Headless() const override;

// Documentation Inherited
public: virtual RenderPassSystemPtr RenderPassSystem() const override;

Expand All @@ -111,6 +117,8 @@ namespace ignition

protected: bool initialized = false;

protected: bool isHeadless = false;

protected: unsigned int nextSceneId;

IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Expand Down
14 changes: 9 additions & 5 deletions ogre2/include/ignition/rendering/ogre2/Ogre2Camera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "ignition/rendering/base/BaseCamera.hh"
#include "ignition/rendering/ogre2/Ogre2RenderTypes.hh"
#include "ignition/rendering/ogre2/Ogre2Includes.hh"
#include "ignition/rendering/ogre2/Ogre2Sensor.hh"

namespace Ogre
Expand Down Expand Up @@ -114,11 +115,7 @@ namespace ignition
public: virtual unsigned int RenderTextureGLId() const override;

// Documentation inherited.
// TODO(anyone): this function should be virtual, declared in 'Camera'
// and 'BaseCamera'. We didn't do it to preserve ABI.
// Looks in commit history for '#SetShadowsNodeDefDirtyABI' to
// see changes made and revert
public: void SetShadowsNodeDefDirty();
public: void SetShadowsDirty() override;

// Documentation inherited.
public: virtual void Destroy() override;
Expand All @@ -144,6 +141,13 @@ namespace ignition
/// \brief Create internal camera object
private: void CreateCamera();

/// \brief Notifies us that the shadow node definition is about to be
/// updated. This means our compositor workspace must be destroyed
/// because the shadow node definition it's using will become a
/// dangling pointer otherwise
/// \sa SetShadowsDirty
private: void SetShadowsNodeDefDirty();

/// \brief Pointer to ogre camera object
protected: Ogre::Camera *ogreCamera = nullptr;

Expand Down
6 changes: 3 additions & 3 deletions ogre2/include/ignition/rendering/ogre2/Ogre2Conversions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include <OgreColourValue.h>
#include <OgreVector3.h>
#include <OgrePixelFormat.h>
#include <OgrePixelFormatGpu.h>

#ifdef _MSC_VER
#pragma warning(pop)
Expand Down Expand Up @@ -107,10 +107,10 @@ namespace ignition
/// \brief Ign-rendering PixelFormat to Ogre PixelFormat
/// \param[in] _v Ign-rendering PixelFormat
/// return Ogre PixelFormat
public: static Ogre::PixelFormat Convert(PixelFormat _format);
public: static Ogre::PixelFormatGpu Convert(PixelFormat _format);

/// \brief A list of ogre pixel formats
private: static const Ogre::PixelFormat ogrePixelFormats[PF_COUNT];
private: static const Ogre::PixelFormatGpu ogrePixelFormats[PF_COUNT];
};
/// \}
}
Expand Down
28 changes: 8 additions & 20 deletions ogre2/include/ignition/rendering/ogre2/Ogre2DepthCamera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -123,26 +123,7 @@ namespace ignition
public: double FarClipPlane() const override;

// Documentation inherited.
// TODO(anyone): this function should be virtual, declared in 'Camera'
// and 'BaseCamera'. We didn't do it to preserve ABI.
// Looks in commit history for '#SetShadowsNodeDefDirtyABI' to
// see changes made and revert
public: void SetShadowsNodeDefDirty();

// TODO(anyone): This fixes the pass quad material leaving dangling
// pointers when we remove the workspace, so we have to cleanup the
// material first.
// This bug was fixed in Ogre 2.2 thus the workaround should not be
// necessary there
//
// See https://github.com/ignitionrobotics/ign-rendering/
// pull/303#pullrequestreview-635228897
// Repro:
// 1.run the sensors_demo.sdf world: ign gazebo -v 4 -r sensors_demo.sdf
// 2.open Lights plugin, top right menu (3 dots) and select Lights
// 3.insert a spot light into the scene (needs to be spot light)
// 4.ign gazebo crashes
private: void RemoveWorkspaceCrashWorkaround();
public: void SetShadowsDirty() override;

// Documentation inherited.
public: void AddRenderPass(const RenderPassPtr &_pass) override;
Expand All @@ -160,6 +141,13 @@ namespace ignition
/// \brief Create the camera.
protected: void CreateCamera();

/// \brief Notifies us that the shadow node definition is about to be
/// updated. This means our compositor workspace must be destroyed
/// because the shadow node definition it's using will become a
/// dangling pointer otherwise
/// \sa SetShadowsDirty
private: void SetShadowsNodeDefDirty();

/// \brief Pointer to the ogre camera
protected: Ogre::Camera *ogreCamera;

Expand Down
59 changes: 33 additions & 26 deletions ogre2/include/ignition/rendering/ogre2/Ogre2Includes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,54 +27,62 @@
// This prevents some deprecation #warning messages on OSX 10.9
#pragma clang diagnostic ignored "-W#warnings"

#include <memory>

#include <Ogre.h>
#include <OgreBillboard.h>
#include <OgreImageCodec.h>
#include <OgreMovableObject.h>
#include <OgreRenderable.h>
#include <OgreRenderWindow.h>
#include <OgrePlugin.h>
#include <OgreCamera.h>
#include <OgreColourValue.h>
#include <OgreDataStream.h>
#include <OgreLogManager.h>
#include <OgreWindowEventUtilities.h>
#include <OgreSceneQuery.h>
#include <OgreRoot.h>
#include <OgreDepthBuffer.h>
#include <OgreFrameListener.h>
#include <OgreGpuProgramManager.h>
#include <OgreHardwareBufferManager.h>
#include <OgreHighLevelGpuProgramManager.h>
#include <OgreItem.h>
#include <OgreSceneManager.h>
#include <OgreSceneNode.h>
#include <OgreVector3.h>
#include <OgreImage2.h>
#include <OgreLogManager.h>
#include <OgreManualObject.h>
#include <OgreMaterialManager.h>
#include <OgreMatrix4.h>
#include <OgreColourValue.h>
#include <OgreQuaternion.h>
#include <OgreMesh2.h>
#include <OgreSubMesh2.h>
#include <OgreMeshManager2.h>
#include <OgreHardwareBufferManager.h>
#include <OgreCamera.h>
#include <OgreMovableObject.h>
#include <OgreNode.h>
#include <OgreSimpleRenderable.h>
#include <OgreFrameListener.h>
#include <OgreTexture.h>
#include <OgreOldSkeletonManager.h>
#include <OgreParticleEmitter.h>
#include <OgreParticleSystem.h>
#include <OgrePass.h>
#include <OgrePixelFormatGpuUtils.h>
#include <OgrePlugin.h>
#include <OgreQuaternion.h>
#include <OgreRectangle2D.h>
#include <OgreRenderObjectListener.h>
#include <OgreRenderable.h>
#include <OgreRoot.h>
#include <OgreSceneManager.h>
#include <OgreSceneNode.h>
#include <OgreSceneQuery.h>
#include <OgreShadowCameraSetupPSSM.h>
#include <OgreSimpleRenderable.h>
#include <OgreStagingTexture.h>
#include <OgreSubMesh2.h>
#include <OgreTechnique.h>
#include <OgrePass.h>
#include <OgreOldSkeletonManager.h>
#include <OgreTextureGpu.h>
#include <OgreTextureGpuManager.h>
#include <OgreTextureUnitState.h>
#include <OgreGpuProgramManager.h>
#include <OgreHighLevelGpuProgramManager.h>
#include <OgreHardwarePixelBuffer.h>
#include <OgreShadowCameraSetupPSSM.h>
#include <OgreDepthBuffer.h>
#include <OgreParticleAffector.h>
#include <OgreParticleAffectorFactory.h>
#include <OgreParticleEmitter.h>
#include <OgreParticleSystem.h>
#include <OgreVector3.h>
#include <OgreWindow.h>
#include <OgreWindowEventUtilities.h>

#include <OgreHlmsManager.h>
#include <OgreHlmsTextureManager.h>
#include <Hlms/Unlit/OgreHlmsUnlit.h>
#include <Hlms/Pbs/OgreHlmsPbs.h>

Expand All @@ -84,7 +92,6 @@
#include <Compositor/OgreCompositorShadowNode.h>
#include <Compositor/OgreCompositorWorkspace.h>
#include <Compositor/OgreCompositorWorkspaceListener.h>
#include <Compositor/Pass/PassClear/OgreCompositorPassClearDef.h>
#include <Compositor/Pass/PassQuad/OgreCompositorPassQuadDef.h>
#include <Compositor/Pass/PassScene/OgreCompositorPassScene.h>
#include <Compositor/Pass/PassScene/OgreCompositorPassSceneDef.h>
Expand Down
2 changes: 1 addition & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2Material.hh
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ namespace ignition

/// \brief Get a pointer to the ogre texture by name
/// \return Ogre texture
protected: virtual Ogre::TexturePtr Texture(const std::string &_name);
protected: virtual Ogre::TextureGpu *Texture(const std::string &_name);

/// \brief Updates the material transparency in the engine,
/// based on transparency and diffuse alpha values
Expand Down
12 changes: 6 additions & 6 deletions ogre2/include/ignition/rendering/ogre2/Ogre2MaterialSwitcher.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <OgreCamera.h>
#include <OgreMaterial.h>
#include <OgreRenderTargetListener.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
Expand All @@ -46,7 +46,7 @@ namespace ignition

/// \brief Helper class to assign unique colors to renderables
class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2MaterialSwitcher :
public Ogre::RenderTargetListener
public Ogre::Camera::Listener
{
/// \brief Constructor
public: explicit Ogre2MaterialSwitcher(Ogre2ScenePtr _scene);
Expand All @@ -65,14 +65,14 @@ namespace ignition
/// \brief Ogre's pre render update callback
/// \param[in] _evt Ogre render target event containing information about
/// the source render target.
public: virtual void preRenderTargetUpdate(
const Ogre::RenderTargetEvent &_evt);
public: virtual void cameraPreRenderScene(
Ogre::Camera *_cam) override;

/// \brief Ogre's post render update callback
/// \param[in] _evt Ogre render target event containing information about
/// the source render target.
public: virtual void postRenderTargetUpdate(
const Ogre::RenderTargetEvent &_evt);
public: virtual void cameraPostRenderScene (
Ogre::Camera * _cam) override;

/// \brief Current unique color value
private: ignition::math::Color currentColor;
Expand Down
10 changes: 10 additions & 0 deletions ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace Ogre
{
class LogManager;
class Root;
class Window;
namespace v1
{
class OverlaySystem;
Expand Down Expand Up @@ -94,6 +95,9 @@ namespace ignition
/// \param[in] _uri Resource path in the form of an uri
public: void AddResourcePath(const std::string &_uri) override;

/// \brief return the ogre window
public: Ogre::Window * OgreWindow() const;

/// \brief Get the ogre2 root object
/// \return ogre2 root object
public: virtual Ogre::Root *OgreRoot() const;
Expand Down Expand Up @@ -138,6 +142,9 @@ namespace ignition
/// \brief Create GL context
private: void CreateContext();

/// \brief Register Hlms
private: void RegisterHlms();

/// \brief Create ogre root
private: void CreateRoot();

Expand Down Expand Up @@ -192,6 +199,9 @@ namespace ignition
/// \brief Dummy window Id needed for linux platform
private: uint64_t dummyWindowId = 0u;

/// \brief Ogre Window
private: Ogre::Window *window = nullptr;

/// \brief True to use the current opengl context
private: bool useCurrentGLContext = false;

Expand Down
Loading

0 comments on commit 7def756

Please sign in to comment.