About render passes

Beginner Getting started

In Using a renderer we have mentioned that render queues and render commands which they contain can be traversed and executed multiple times - each time using a different shader, different configuration etc. The individual steps when rendering a scene this way are commonly referred to as "render passes". Here you will learn in a little more detail how render passes work in BBMOD.

Contents

Render passes

In context of BBMOD, a render pass is a moment when the entire scene or its portion is rendered into a surface (could be the application surface or other). The final image displayed on the screen (before post-processing) is then composed using the contents of these surfaces. BBMOD comes with a pre-defined set of render passes and you can find them in enumeration BBMOD_ERenderPass.

To give you an example, BBMOD uses shadow mapping to render dynamic shadows. This technique requires a depth buffer to be rendered first from the light's perspective, which is then used in the main pass to check whether a rendered fragment is in shadow or not. BBMOD renders models into a shadow map during the Shadows render pass. Whether a model casts shadows or not (i.e. is rendered into the shadow map or not) depends on the configuration of the material it uses.

Functions bbmod_render_pass_set and bbmod_render_pass_get can be used to configure the current render pass. Please note that unless you are writing your own renderer, you do not need to use these functions, as BBMOD renderers change the render passes automatically as required!

Material configuration

Each material can define which shader it uses in each individual render pass. If it does not define the shader, then it is not rendered in that specific render pass. BBMOD_Material provides methods set_shader, has_shader, get_shader and remove_shader, using which you can configure shaders used in individual render passes.

To follow on our shadows example, here is a code snippet that adds a shader for the Shadows render pass into a material:

material = BBMOD_MATERIAL_DEFAULT.clone();
material.set_shader(BBMOD_ERenderPass.Shadows, BBMOD_SHADER_DEFAULT_DEPTH);

Note that we are using shader BBMOD_SHADER_DEFAULT_DEPTH here, since the Shadows render pass renders a depth buffer.

The default rendering pipeline

After you configure a material's shaders used in individual render passes, whether it is actually rendered or not also depends on whether the used renderer implements the render passes. As you have learnt in the Using a renderer tutorial, the renderer is what traverses existing render queues and executes their commands after all. For example, if the used renderer does not enable the Shadows render pass, execute render commands while a shadow map surface is set as the current render target and does not pass the shadow map into shaders, you will not have shadows in your game even if the materials are set up correctly!

Renderer BBMOD_DefaultRenderer implements a forward rendering pipeline and at the time of writing this tutorial it supports render passes ReflectionCapture, Id, Shadows, DepthOnly, Forward and Alpha. Please see its documentation for the most up-to-date info.

You will learn how to implement your own renderer in a future tutorial.

Could not find what you were looking for?

We are still working on more tutorials. If you need additional help with BBMOD, please have a look at the documentation or join our Discord community. Thank you for your patience.

Support the development

Support us in developing BBMOD, get priority assistance and more of our amazing tools as a reward!

Become Patron

Don't miss out on a thing!

Create an account, subscribe to newsletter and get notified on new releases, tutorials and special offers.

Register Log in