Class RenderPass

Class Hierarchy

RenderPass is the base class for Kanzi render passes.

Use render passes to perform singular render pass operations in 3D scenes. For example, use a render pass to clear the background, render nodes for a specific object source, set up a composition target, and so on.

Combine render passes into a hierarchy to create the rendering result you want to achieve.

Render pass rendering and execution order

The base RenderPass class does not implement any functionality, but renders its descendant render passes. This is the reason why the base RenderPass class is called Group Render Pass in Kanzi Studio. All other render passes either perform draw operations or set the state for successive render passes. In both cases, they pass the control to their descendant render passes only after they execute their own operations. Keep this in mind when you define your own render passes. See Creating your own render pass.

Render passes that perform draw operations are:

  • BlitRenderPass
  • ClearRenderPass
  • DrawObjectsRenderPass
  • DrawObjectsWithMaterialRenderPass

Render passes that set state are:

  • CompositionTargetRenderPass
  • MaterialSetupRenderPass
  • PipelineStateRenderPass

Kanzi executes render passes by iterating the tree depth-first. This is similar to how Kanzi iterates nodes when it renders the node tree. Each render pass first executes itself, then, one at a time, all of its child render passes. Since the child render passes execute themselves, Kanzi executes the full tree starting from a child render pass before it executes the next child render pass. In the same way, the successive Kanzi executes the sibling render passes before it returns the control returns to the parent render pass.

Using textures created with render passes

You can use a render pass to create a texture and then use that texture in other render passes. The texture bindings are resolved on render. For example, you can show on the screen a texture that a CompositionTargetRenderPass creates, with a BlitRenderPass.

Creating render passes

When you create a render pass, the create function calls the constructor, initializes the render pass, and returns the pointer to the render pass. The render pass constructors are protected and only inheriting classes can access them.

Render pass hierarchy

You can combine render passes into a hierarchy to create the rendering result you cannot achieve with any single render pass. When you select a render pass for a Scene or a Viewport2D node, you can select either the root render pass or a specific render pass within such hierarchy. If you select a specific render pass within such hierarchy, Kanzi uses only that render pass and its descendants to render the content.

If a render pass is the root of its own tree, it does not have a parent render pass. In the same manner, if a render pass is a leaf render pass, it does not have any child render passes.

Creating your own render pass class

If you cannot achieve the rendering result with the render passes that come with Kanzi, you can create your own render pass.

Defining the class

Start creating your own render pass by inheriting from the RenderPass base class. Define metaclass and declare property types in the same way as you would in the Node classes. See Node2D.

RenderPass override functions

When you need to override the functionality of the RenderPass class, override the renderOverride() virtual

Since Kanzi 3.9.8 changed to derive from GPUResource instead of Resource.

Use a Group render pass to group render passes so that you can refer to a single render pass in your Scene.

Inherits properties and message types from RenderPassMetadata.

Synopsis

Methods
create()

Create a render pass

RenderPass.RenderPass:create(name)

Create a render pass.

Parameters
name (string)

The name for the render pass.