Render passes

In Using a renderer we have mentioned that render queues and render commands that 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". BBMOD library comes with a defined set of these passes and you can find them in enumeration BBMOD_ERenderPass.

Default rendering pipeline

The default renderer currently implements a simple two-pass rendering pipeline, where shadow-casting models are first rendered into an off-screen surface (shadowmap) in the Shadows render pass and the surface is then used in a Forward render pass, during which is the final shaded scene rendered into the application surface. Please note that post-processing stands outside of this system and it is handled separately when the application surface is drawn onto the screen.

It is possible to create a custom renderer with a custom rendering pipeline, but that is a topic outside of the scope of this section.

Defining shaders for individual render passes

When you see the documentation of BBMOD_BaseMaterial, you will learn that the shader passed to its constructor is used in the Forward render pass. This means that any mesh that uses the material will be rendered only in a forward render pass, unless you specify shaders used in other render passes too. For this you can use the method set_shader.

For example, when you use the default renderer and you want to render models using a material into the shadowmap (so they cast shadows), you can configure the material to use BBMOD_SHADER_DEPTH (or BBMOD_SHADER_DEPTH_ANIMATED for animated models) in the Shadows render pass like so:

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

// Or for animated models:

material = BBMOD_MATERIAL_DEFAULT_ANIMATED.clone()
    .set_shader(BBMOD_ERenderPass.Shadows, BBMOD_SHADER_DEPTH_ANIMATED);

There are also methods has_shader, get_shader and remove_shader, using which you can check if a material has a shader defined for a specific render pass, retrieve the shader or remove it respectively.

Do you find this page helpful?

Copyright © 2022, BlueBurn. Built on May 18, 2022 using GMDoc.