Skip to content

Commit

Permalink
WideAngleCamera: specify cube map texture format
Browse files Browse the repository at this point in the history
The WideAngleCamera has a texture for a cube map that
uses the same pixel format as the camera image. If there
are intermediate shaders applied to the camera, the choice
of this image format may cause pixel values to be truncated.
To provide flexibility to the user, the pixel format for
the cube map texture can be specified with a custom SDFormat
element in `//camera/lens/gazebo:env_texture_format`
using the same values as `//camera/image/format`.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
  • Loading branch information
scpeters committed Feb 4, 2021
1 parent 6575309 commit d3793e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 12 additions & 1 deletion gazebo/rendering/WideAngleCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ void WideAngleCamera::Load()
{
Camera::Load();

// Cube map texture format defaults to matching image pixel format
this->dataPtr->envCubeMapTextureFormat =
static_cast<Ogre::PixelFormat>(this->imageFormat);

this->CreateEnvCameras();

if (this->sdf->HasElement("lens"))
Expand All @@ -467,6 +471,13 @@ void WideAngleCamera::Load()

if (sdfLens->HasElement("env_texture_size"))
this->dataPtr->envTextureSize = sdfLens->Get<int>("env_texture_size");

const std::string envTextureFormat = "gazebo:env_texture_format";
if (sdfLens->HasElement(envTextureFormat))
{
this->dataPtr->envCubeMapTextureFormat = static_cast<Ogre::PixelFormat>(
this->OgrePixelFormat(sdfLens->Get<std::string>(envTextureFormat)));
}
}
else
this->dataPtr->lens->Load();
Expand Down Expand Up @@ -660,7 +671,7 @@ void WideAngleCamera::CreateEnvRenderTexture(const std::string &_textureName)
this->dataPtr->envTextureSize,
this->dataPtr->envTextureSize,
0,
static_cast<Ogre::PixelFormat>(this->imageFormat),
this->dataPtr->envCubeMapTextureFormat,
Ogre::TU_RENDERTARGET,
0,
false,
Expand Down
4 changes: 4 additions & 0 deletions gazebo/rendering/WideAngleCameraPrivate.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <mutex>

#include "gazebo/msgs/msgs.hh"
#include "gazebo/rendering/ogre_gazebo.h"
#include "gazebo/util/system.hh"


Expand Down Expand Up @@ -59,6 +60,9 @@ namespace gazebo
/// \brief Viewports for the render targets
public: Ogre::Viewport *envViewports[6];

/// \brief Pixel format for cube map texture
public: Ogre::PixelFormat envCubeMapTextureFormat;

/// \brief A single cube map texture
public: Ogre::Texture *envCubeMapTexture;

Expand Down

0 comments on commit d3793e3

Please sign in to comment.