Skip to content

Commit d3793e3

Browse files
committed
WideAngleCamera: specify cube map texture format
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>
1 parent 6575309 commit d3793e3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

gazebo/rendering/WideAngleCamera.cc

+12-1
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,10 @@ void WideAngleCamera::Load()
457457
{
458458
Camera::Load();
459459

460+
// Cube map texture format defaults to matching image pixel format
461+
this->dataPtr->envCubeMapTextureFormat =
462+
static_cast<Ogre::PixelFormat>(this->imageFormat);
463+
460464
this->CreateEnvCameras();
461465

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

468472
if (sdfLens->HasElement("env_texture_size"))
469473
this->dataPtr->envTextureSize = sdfLens->Get<int>("env_texture_size");
474+
475+
const std::string envTextureFormat = "gazebo:env_texture_format";
476+
if (sdfLens->HasElement(envTextureFormat))
477+
{
478+
this->dataPtr->envCubeMapTextureFormat = static_cast<Ogre::PixelFormat>(
479+
this->OgrePixelFormat(sdfLens->Get<std::string>(envTextureFormat)));
480+
}
470481
}
471482
else
472483
this->dataPtr->lens->Load();
@@ -660,7 +671,7 @@ void WideAngleCamera::CreateEnvRenderTexture(const std::string &_textureName)
660671
this->dataPtr->envTextureSize,
661672
this->dataPtr->envTextureSize,
662673
0,
663-
static_cast<Ogre::PixelFormat>(this->imageFormat),
674+
this->dataPtr->envCubeMapTextureFormat,
664675
Ogre::TU_RENDERTARGET,
665676
0,
666677
false,

gazebo/rendering/WideAngleCameraPrivate.hh

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <mutex>
2121

2222
#include "gazebo/msgs/msgs.hh"
23+
#include "gazebo/rendering/ogre_gazebo.h"
2324
#include "gazebo/util/system.hh"
2425

2526

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

63+
/// \brief Pixel format for cube map texture
64+
public: Ogre::PixelFormat envCubeMapTextureFormat;
65+
6266
/// \brief A single cube map texture
6367
public: Ogre::Texture *envCubeMapTexture;
6468

0 commit comments

Comments
 (0)