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/ignitionrobotics/ign-rendering
cd ign-rendering/examples/render_pass
mkdir build
cd build
cmake ..
make
Execute the example:
./render_pass
You'll see:
[Msg] Loading plugin [ignition-rendering6-ogre]
Engine 'optix' is not supported
===============================
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);
if (rpSystem)
{
// add gaussian noise pass
RenderPassPtr pass = rpSystem->Create<GaussianNoisePass>();
if (pass)
{
GaussianNoisePassPtr noisePass =
std::dynamic_pointer_cast<GaussianNoisePass>(pass);
noisePass->SetMean(0.1);
noisePass->SetStdDev(0.08);
camera->AddRenderPass(noisePass);
}
// add distortion pass
pass = rpSystem->Create<DistortionPass>();
if (pass)
{
DistortionPassPtr distortionPass =
std::dynamic_pointer_cast<DistortionPass>(pass);
distortionPass->SetK1(0.5);
camera->AddRenderPass(distortionPass);
}
}
RenderEngine * engine(const std::string &_name, const std::map< std::string, std::string > &_params={}, const std::string &_path="")
Get the render-engine registered under the given name. If no render-engine is registered under the gi...
shared_ptr< GaussianNoisePass > GaussianNoisePassPtr
Shared pointer to GaussianNoisePass.
Definition: gz/rendering/RenderTypes.hh:139
shared_ptr< RenderPassSystem > RenderPassSystemPtr
Shared pointer to RenderPassSystem.
Definition: gz/rendering/RenderTypes.hh:231
virtual RenderPassSystemPtr RenderPassSystem() const =0
Get the render pass system for this engine.
shared_ptr< Camera > CameraPtr
Shared pointer to Camera.
Definition: gz/rendering/RenderTypes.hh:107
shared_ptr< RenderPass > RenderPassPtr
Shared pointer to RenderPass.
Definition: gz/rendering/RenderTypes.hh:227
shared_ptr< DistortionPass > DistortionPassPtr
Shared pointer to DistortionPass.
Definition: gz/rendering/RenderTypes.hh:135