Gazebo Rendering

API Reference

9.0.0~pre2
Render pass

This example demonstrates the use of the render pass system for adding Gaussian noise post-processing effect to a camera.

Compile and run the example

Clone the source code, create a build directory and use cmake and make to compile the code:

git clone https://github.com/gazebosim/gz-rendering
cd gz-rendering/examples/render_pass
mkdir build
cd build
cmake ..
make

Execute the example:

./render_pass

You'll see:

[Msg] Loading plugin [gz-rendering9-ogre]
===============================
TAB - Switch render engines
ESC - Exit
===============================

Code

Get the render pass system and create a Gaussian noise render pass. Then we just need to set the noise mean and the standard deviation parameters and apply this render pass to the camera.

CameraPtr camera = std::dynamic_pointer_cast<Camera>(sensor);
RenderPassSystemPtr rpSystem = engine->RenderPassSystem();
if (rpSystem)
{
// add gaussian noise pass
RenderPassPtr pass = rpSystem->Create<GaussianNoisePass>();
if (pass)
{
GaussianNoisePassPtr noisePass =
noisePass->SetMean(0.1);
noisePass->SetStdDev(0.08);
camera->AddRenderPass(noisePass);
}
// add distortion pass
pass = rpSystem->Create<DistortionPass>();
if (pass)
{
DistortionPassPtr distortionPass =
distortionPass->SetK1(0.5);
camera->AddRenderPass(distortionPass);
}
}