Skip to content

Render processes

Romain Milbert edited this page Nov 12, 2024 · 6 revisions

In RaZ, a "render process" is a predefined set of render passes, from 1 to any number, executing specific shaders that operate on read buffers and can write to others. This allows for an easier setup compared to plain render passes while remaining very customizable.

To run a render process, it needs to be added to the render graph, e.g. for a box blur process:

#include <RaZ/Render/BoxBlurRenderProcess.hpp>

...

Raz::RenderSystem& renderSystem = world.addSystem<Raz::RenderSystem>(...);
Raz::RenderGraph& renderGraph   = renderSystem.getRenderGraph();

Raz::BoxBlurRenderProcess& boxBlur = renderGraph.addRenderProcess<Raz::BoxBlurRenderProcess>();

Next, buffers must be added to read and potentially write to:

auto inputBuffer = Raz::Texture2D::create(...);
boxBlur.setInputBuffer(inputBuffer);

// You can also set an output buffer if you need it to be used by another pass
auto outputBuffer = Raz::Texture2D::create(...);
boxBlur.setOutputBuffer(outputBuffer);

Note that some render processes can take multiple read and/or write buffers, and so can have different names for these functions.

Finally, just as with regular render passes, parenting needs to be set up properly. The member functions addParent() and addChild() are available to do just that; each can take either another render process or a simple render pass:

Raz::RenderPass& geometryPass = renderGraph.getGeometryPass();
boxBlur.addParent(geometryPass);

SomeRenderProcess& otherProcess = renderGraph.addRenderProcess<SomeRenderProcess>();
boxBlur.addChild(otherProcess);

Each process can have any function they see fit. For instance, the box blur has a setStrength() function, allowing to make the blur's strength vary at any time.

Processes can also be enabled or disabled with their respective enable() & disable() functions (or equivalenty setState(true) and setState(false)).

⚠️ Deactivating processes may not do well due to the inner rigidity of the render graph. Specifically, as the process' write buffers are never written to, they end up empty and are given as-is to subsequent passes, which can obviously lead to issues. No pass or process currently ever does a simple passthrough; should you change any process' state, you remain the sole responsible for your rendering to be done properly (e.g. by having a pass that's set to be active when the main one isn't).


Several premade render processes are available (such as bloom, blur, SSR, ...), but anyone can do their own. It just need to inherits from the base class Raz::RenderProcess, available from RaZ/Render/RenderProcess.hpp, and reimplement the necessary functions properly. For simplicity, there also exists Raz::MonoPassRenderProcess, available from RaZ/Render/MonoPassRenderProcess.hpp, that can be inherited from to have a render process with a single pass that's easier to setup.

Clone this wiki locally