rhodonite
    Preparing search index...

    Class RenderPass

    A render pass represents a collection of rendering resources and settings used in the rendering pipeline. It manages entities, materials, framebuffers, and various rendering states to control how objects are rendered.

    const renderPass = new RenderPass();
    renderPass.addEntities([entity1, entity2]);
    renderPass.setFramebuffer(framebuffer);
    renderPass.toClearColorBuffer = true;
    renderPass.clearColor = Vector4.fromCopyArray([0.2, 0.3, 0.4, 1.0]);

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    __renderTargetColorAttachments?: RenderBufferTargetEnum[]

    Color attachment targets for rendering

    _drawVertexNumberForBufferLessRendering: number = 0

    If this value is greater than 1, buffer-less rendering is performed with the specified number of vertices. In this case, registered entities are ignored and not rendered.

    _dummyPrimitiveForBufferLessRendering: Primitive

    A dummy primitive used for buffer-less rendering

    _isChangedSortRenderResult: boolean = false

    Whether the sort render result has changed

    _lastBlendWithoutZWriteIndex: number = -1

    Last index of blend without Z-write primitives in the render queue

    _lastBlendWithZWriteIndex: number = -1

    Last index of blend with Z-write primitives in the render queue

    _lastCameraControllerComponentsUpdateCount: number = -1

    Last camera controller components update count for change detection

    _lastOpaqueIndex: number = -1

    Last index of opaque primitives in the render queue

    _lastPrimitiveUids: number[] = []

    Array of last primitive UIDs for optimization

    _lastSceneGraphComponentsUpdateCount: number = -1

    Last scene graph components update count for change detection

    _lastTransformComponentsUpdateCount: number = -1

    Last transform components update count for change detection

    _lastTranslucentIndex: number = -1

    Last index of translucent primitives in the render queue

    _primitiveModeForBufferLessRendering: PrimitiveModeEnum = PrimitiveMode.Triangles

    The primitive mode used for buffer-less rendering

    _renderedSomethingBefore: boolean = true

    Whether something was rendered in the previous frame

    _tags: RnTags = {}

    Collection of tags associated with this object

    _toRenderBlendWithoutZWritePrimitives: boolean = true

    Whether to render blend without Z-write primitives contained in this render pass

    _toRenderBlendWithZWritePrimitives: boolean = true

    Whether to render blend with Z-write primitives contained in this render pass

    _toRenderOpaquePrimitives: boolean = true

    Whether to render opaque primitives contained in this render pass

    _toRenderTranslucentPrimitives: boolean = true

    Whether to render translucent primitives contained in this render pass

    cameraComponent?: CameraComponent

    The camera component used for rendering this pass

    clearColor: Vector4 = ...

    The color value used to clear the color buffer (RGBA format)

    clearDepth: number = 1

    The depth value used to clear the depth buffer (typically 1.0 for far plane)

    clearStencil: number = 0

    The stencil value used to clear the stencil buffer

    depthWriteMask: boolean = true

    Depth write mask for primitives drawing. When false, depth values are not written to the depth buffer, but depth clear is still performed.

    isDepthTest: boolean = true

    Whether to enable depth testing during rendering

    isOutputForVr: boolean = false

    Whether this render pass outputs for VR display

    isVrRendering: boolean = true

    Whether VR rendering is enabled for this render pass

    toClearColorBuffer: boolean = false

    Whether to clear the color buffer before rendering

    toClearDepthBuffer: boolean = true

    Whether to clear the depth buffer before rendering

    toClearStencilBuffer: boolean = false

    Whether to clear the stencil buffer before rendering

    toRenderEffekseerEffects: boolean = false

    Whether to render Effekseer effects in this render pass

    __mesh_uid_count: number = -1

    Static counter for generating unique mesh UIDs

    currentMaxObjectCount: number = 0

    Current maximum object count for UID generation

    InvalidObjectUID: -1

    Invalid object UID constant

    Accessors

    • get _optimizedMeshComponents(): MeshComponent[]
      Internal

      Gets the optimized mesh components collection for rendering. This collection is filtered based on the rendering flags for different primitive types.

      Returns MeshComponent[]

      An array of mesh components that should be rendered

    • get objectUID(): number

      Gets the unique object identifier

      Returns number

      The object's UID

    • get uniqueName(): string

      Gets the unique name of this object

      Returns string

      The unique name string

    Methods

    • Internal

      Copies the main framebuffer content to both resolve framebuffers using WebGL. This method handles the blit operations for multisampling resolve.

      Returns void

    • Internal

      Copies texture data from the first resolve framebuffer to the second using WebGPU. This method handles texture copying operations for WebGPU-based rendering.

      Returns void

    • Adds entities to be rendered in this render pass. The entities and their hierarchies are flattened and collected for rendering. Duplicate entities are automatically eliminated.

      Parameters

      Returns void

    • Removes all entities from this render pass and clears related collections. This effectively empties the render pass of all renderable content.

      Returns void

    • Internal

      Executes the post-render function if one has been set. This method is called internally by the rendering system.

      Returns void

    • Internal

      Executes the pre-render function if one has been set. This method is called internally by the rendering system.

      Returns void

    • Determines the appropriate material to use for rendering a primitive. The priority order is:

      1. Primitive-specific material (set via setMaterialForPrimitive)
      2. Render pass default material (set via setMaterial)
      3. Primitive's own material

      Parameters

      • primitive: Primitive

        The primitive to get the material for

      Returns Material

      The material that should be used for rendering the primitive

    • Retrieves a complete tag object (name and value) for the specified tag name

      Parameters

      • tagName: string

        The name of the tag to retrieve

      Returns Tag

      A Tag object containing the name and value

    • Retrieves the value associated with a specific tag name

      Parameters

      • tagName: string

        The name of the tag whose value to retrieve

      Returns any

      The tag value, or undefined if the tag doesn't exist

    • Checks whether this object has a tag with the specified name

      Parameters

      • tagName: string

        The name of the tag to check for

      Returns boolean

      True if the tag exists (value is not null/undefined), false otherwise

    • Checks if this render pass is in buffer-less rendering mode.

      Returns boolean

      True if buffer-less rendering is enabled (vertex count > 0)

    • Checks if this object has a tag with the specified name and value

      Parameters

      • tagName: string

        The tag name to match

      • tagValue: string

        The tag value to match

      Returns boolean

      True if the object has a matching tag, false otherwise

    • Checks if this object has all the specified tags with exactly matching values

      Parameters

      • tags: RnTags

        Object containing tag names as keys and expected values

      Returns boolean

      True if all specified tags exist with matching values, false otherwise

    • Checks if the object's combined tag string contains all the provided search strings. This allows for flexible searching within tag names and values.

      Parameters

      • stringArray: string[]

        Array of strings that must all be present in the combined tag string

      Returns boolean

      True if all strings are found in the combined tag string, false otherwise

    • Removes the current framebuffer assignment. After calling this, the render pass will render to the default framebuffer.

      Returns void

    • Configures this render pass for full-screen buffer-less rendering. This is a convenience method that sets up triangle-based full-screen rendering with 3 vertices, commonly used for post-processing effects.

      Parameters

      • material: Material

        The material to use for full-screen rendering

      Returns void

    • Configures this render pass for buffer-less rendering mode. In buffer-less rendering, vertices are generated procedurally without vertex buffers. This is useful for full-screen effects or procedural geometry. When enabled, registered entities are ignored and not rendered.

      Parameters

      • primitiveMode: PrimitiveModeEnum

        The primitive mode to use for rendering

      • drawVertexNumberWithoutEntities: number

        Number of vertices to generate and render

      • material: Material

        The material to use for rendering

      Returns void

    • Sets the target framebuffer for this render pass. If multiple render passes share a framebuffer, they will render to the same target. Setting a framebuffer automatically configures the viewport to match the framebuffer size.

      Parameters

      • Optionalframebuffer: FrameBuffer

        The framebuffer to render to, or undefined to render to the default framebuffer

      Returns void

    • Sets a default material for all primitives in this render pass. This material will be used for any primitive that doesn't have a specific material override set via setMaterialForPrimitive().

      Parameters

      • material: Material

        The default material to use for all primitives

      Returns void

    • Associates a specific material with a primitive for this render pass. When rendering the specified primitive, the render pass will use this material instead of the primitive's default material.

      Parameters

      • material: Material

        The material to use for the primitive

      • primitive: Primitive

        The target primitive to override the material for

      Returns void

    • Sets a function to be called after each render operation. This can be used for custom cleanup logic after rendering completes.

      Parameters

      • func: () => void

        The function to call after rendering

      Returns void

    • Sets a function to be called before each render operation. This can be used for custom setup logic before rendering begins.

      Parameters

      • func: () => void

        The function to call before rendering

      Returns void

    • Sets the resolve framebuffer for multisampling. The resolve framebuffer is used as the destination when resolving multisampled content.

      Parameters

      • Optionalframebuffer: FrameBuffer

        The resolve framebuffer, or undefined to disable resolving

      Returns void

    • Sets the secondary resolve framebuffer. This can be used for additional resolve operations or multi-target resolving.

      Parameters

      • Optionalframebuffer: FrameBuffer

        The secondary resolve framebuffer, or undefined to disable

      Returns void

    • Sets whether to render blend without Z-write primitives in this render pass.

      Parameters

      • toRender: boolean

        True to render blend without Z-write primitives, false to skip them

      Returns void

    • Sets whether to render blend with Z-write primitives in this render pass.

      Parameters

      • toRender: boolean

        True to render blend with Z-write primitives, false to skip them

      Returns void

    • Sets whether to render opaque primitives in this render pass.

      Parameters

      • toRender: boolean

        True to render opaque primitives, false to skip them

      Returns void

    • Sets whether to render translucent primitives in this render pass.

      Parameters

      • toRender: boolean

        True to render translucent primitives, false to skip them

      Returns void

    • Sets the viewport for this render pass. The viewport defines the rectangular area of the framebuffer that will be rendered to.

      Parameters

      • vec: IVector4

        A Vector4 containing (x, y, width, height) of the viewport

      Returns void

    • Attempts to set a tag on this object. If the tag already exists, it will be replaced.

      Parameters

      • tag: Tag

        The tag object containing the name and value to set

      Returns boolean

      True if the tag was successfully set, false if the tag name contains invalid characters

    • Attempts to set a unique name for this object

      Parameters

      • name: string

        The desired unique name

      • toAddNameIfConflict: boolean

        If true, appends UID to make name unique when conflicts occur; if false, fails on conflict

      Returns boolean

      True if the name was successfully set, false if there was a conflict and toAddNameIfConflict was false

    • Validates that a tag string contains only allowed characters (alphanumeric and underscore)

      Parameters

      • val: string

        The string to validate

      Returns boolean

      True if the string contains only valid characters, false if it contains invalid characters

    • Retrieves an RnObject instance by its unique identifier

      Parameters

      • objectUid: number

        The unique identifier of the object to retrieve

      Returns RnObject | undefined

      The RnObject instance or undefined if not found or garbage collected

    • Searches for the first object that has a specific tag with the given value

      Parameters

      • tag: string

        The tag name to search for

      • value: string

        The tag value to match

      Returns WeakRef<RnObject> | undefined

      WeakRef to the first matching object, or undefined if not found