Engine API Reference - v2.24.0-beta.28
    Preparing search index...

    Class FramePass

    A frame pass represents a node in the frame graph. It encapsulates a unit of work that executes during frame rendering. Subclasses include RenderPass for GPU render passes with render targets, and non-rendering passes for compute dispatches or other tasks.

    In each frame a pass is part of, for example as a frame pass of a camera, or as a before or after pass of another pass, it goes through these steps:

    A pass can also be rendered on its own, outside of a frame, by calling FramePass#render.

    Hierarchy (View Summary)

    Index
    afterPasses: FramePass[] = []

    Frame passes which need to be executed after this pass. This pass does not own them, and does not destroy them: whoever adds a pass to the list destroys it.

    beforePasses: FramePass[] = []

    Frame passes which need to be executed before this pass. The engine does not change this list, so the passes in it execute every frame this pass executes. This pass does not own them, and does not destroy them: whoever adds a pass to the list destroys it.

    The graphics device.

    executeEnabled: boolean = true

    True if the frame pass is enabled and execute function will be called. Note that before and after functions are called regardless of this flag. Set it before the frame renders, at the latest in frameUpdate, as the frame graph decides which passes to merge from it.

    onAfter: ((pass: FramePass) => void) | null = null

    Called when the pass renders, right after it executes: for a render pass once its GPU render pass has ended, and after FramePass#after. The results the pass writes can be read back here, as a read records its copy when it is requested, and so right after the pass. Reads should not be immediate, as that submits the work of the frame recorded so far. Like after, it is called even if FramePass#executeEnabled is false, but not when the pass is disabled. A render pass with this callback is not merged with the pass after it into a single GPU render pass, so the callback runs outside of one.

    onBefore: ((pass: FramePass) => void) | null = null

    Called when the pass renders, right before it executes: after FramePass#before, and for a render pass before its GPU render pass starts. Work recorded here, such as setting the parameters of the pass, or clearing a buffer it writes to, executes right before the pass. Like before, it is called even if FramePass#executeEnabled is false, but not when the pass is disabled. A render pass with this callback is not merged with the pass before it into a single GPU render pass, so the callback runs outside of one.

    • get enabled(): boolean

      Gets whether the frame pass is enabled.

      Returns boolean

    • set enabled(value: boolean): void

      Sets whether the frame pass is enabled. A disabled pass is skipped when the frame is built, together with its FramePass#beforePasses and FramePass#afterPasses, and its frameUpdate is not called. To skip only the execution of the pass, while still updating it and its before and after passes, use FramePass#executeEnabled instead. Change it before the frame is built: the frameUpdate of a pass, or of its before-passes, cannot disable the pass itself. Defaults to true.

      Parameters

      • value: boolean

      Returns void

    • get name(): string

      Gets the name of the pass.

      Returns string

    • set name(value: string): void

      Sets the name of the pass, which identifies it in debug output, GPU profiling and graphics debuggers. Defaults to the name of its class, which minified builds can shorten, so set it explicitly for a readable name.

      Parameters

      • value: string

      Returns void

    • Releases the resources the pass created. A pass owns only what it creates: it does not destroy its FramePass#beforePasses and FramePass#afterPasses, which are destroyed by whoever added them. The code which creates a pass destroys it, once, and the pass is not used after that - in debug builds, adding a destroyed pass to a frame reports an error. Subclasses releasing their own resources call super.destroy().

      Returns void

    • Called each frame the pass is added to the frame, while the frame is built and before anything renders, and before its FramePass#beforePasses and FramePass#afterPasses are added. Override to update the pass for the frame, for example to resize its render targets, to set the textures it reads, to add or remove its before and after passes and enable or disable them, or to set its FramePass#executeEnabled. It cannot disable the pass itself. It is not called for a disabled pass, nor when the pass is rendered on its own with FramePass#render.

      Returns void

    • Called when the pass is disabled, by setting FramePass#enabled to false while it is true. Override to release what the pass does not need while it is disabled, such as its render targets.

      Returns void