Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AccumulatePass

This pass accumulates the color attachment 0 of a framebuffer, e.g., the result of an intermediate frame, into an accumulation buffer. For accumulation the frame number is used to derive the accumulation weight. For rendering to texture, a textured ndc-filling triangle is used.

The accumulation pass can be used as follows:

this.accumulate.initialize();
this.accumulate.texture = this.intermediateFBO.texture(gl2facade.COLOR_ATTACHMENT0);
this.accumulate.update();
this.accumulate.frame(frameNumber);

Hierarchy

Index

Constructors

constructor

Properties

Protected _accumulationFBOs

_accumulationFBOs: [Framebuffer, Framebuffer]

Two rgba-framebuffers used for accumulation (buffer ping-ponging is used for alternating the buffers for read and write access due to a limitation in WebGL).

Protected _accumulationTextures

_accumulationTextures: [Texture2D, Texture2D]

Protected Readonly _altered

_altered: ChangeLookup & { any: boolean; passThrough: boolean; precision: boolean; texture: boolean } = ...

Alterable auxiliary object for tracking changes on this object's input and lazy updates.

Protected _context

_context: Context

Read-only access to the objects context, used to get context information and WebGL API access.

Protected _ndcTriangle

_ndcTriangle: NdcFillingTriangle

Geometry used to draw on. This is not provided by default to allow for geometry sharing. If no triangle is given, the ndc triangle will be created and managed internally.

Protected _ndcTriangleShared

_ndcTriangleShared: boolean = false

Tracks ownership of the ndc-filling triangle.

Protected _passThrough

_passThrough: boolean

Protected _precision

_precision: Precision = ...
see

precision

Protected _program

_program: Program

Protected _texture

_texture: Texture2D
see

texture

Protected _uWeight

_uWeight: WebGLUniformLocation

Protected _write

_write: number = 0

Stores the index of the last buffer written to.

Protected assertInitialized

assertInitialized: () => void = ...

Asserts the objects initialization status to be true. Note that the implementation is cached and forwarded to either an empty function when initialized and to an acutal assert(false) otherwise.

Type declaration

    • (): void
    • Returns void

Protected assertUninitialized

assertUninitialized: () => void = ...

Asserts the objects initialization status to be false. Note that the implementation is cached and forwarded to either an empty function when uninitialized and to an acutal assert(false) otherwise.

Type declaration

    • (): void
    • Returns void

Accessors

framebuffer

  • Returns the framebuffer last accumulated into. Note: the accumulation buffer is represented by two framebuffers swapped for read and write every frame. The accumulation result is in the first color attachment.

    Returns undefined | Framebuffer

    • The rgba framebuffer last accumulated into.

initialized

  • get initialized(): boolean
  • Property getter for readonly access to the initialization status of an initializable instance.

    Returns boolean

passThrough

  • set passThrough(passThrough: boolean): void
  • Allows to skip accumulation. If pass through is enabled, nothing will be rendered on frame at all and the ping pong render textures will be reduced to a minimum size of [1, 1] until pass through is disabled.

    Parameters

    • passThrough: boolean

    Returns void

precision

texture

  • Sets the texture that is to be accumulated. The ping and pong render textures will be resized on next frame automatically if the texture size changed.

    Parameters

    • texture: Texture2D

      Framebuffer that is to be accumulated.

    Returns void

Methods

frame

  • frame(frameNumber: number, viewport?: GLsizei2): void
  • An accumulation frame binds the two accumulation textures (ping-pong framebuffer), one for read, the other for write/accumulating into. A screen-aligned triangle is used to fill the viewport and mix the input texture with the weight of 1 / (frameNumber + 1) with the previous accumulation result. If no texture is specified, pass through is used.

    Parameters

    • frameNumber: number

      Frame number used to select the current read and write framebuffer as well as frame weight.

    • Optional viewport: GLsizei2

      If specified, the viewport for accumulation will be set to the given width and height. If not, the currently set viewport is used.

    Returns void

initialize

  • Specializes this pass's initialization. This pass requires an ndc-filling triangle, a single accumulation program, and two accumulation framebuffers for ping pong (simultaneous read and write is currently not allowed by webgl). All attribute and dynamic uniform locations are cached.

    Parameters

    • Optional ndcTriangle: NdcFillingTriangle

      If specified, assumed to be used as shared geometry. If none is specified, a ndc-filling triangle will be created internally.

    Returns boolean

uninitialize

  • uninitialize(): void

update

  • update(): void
  • Initialize accumulation textures and FBOs (if not initialized yet). Then verifies if the texture's size has changed, and if so, resizes the accumulation buffers.

    Returns void

Static Protected Readonly assertInitializedFalse

Static Protected Readonly assertUninitializedFalse

Static assert_initialized

  • assert_initialized(): MethodDecorator

Static assert_uninitialized

  • assert_uninitialized(): MethodDecorator

Static discard

  • discard(): MethodDecorator
  • Method decorator for discarding of Initializable inheritors. This decorator asserts the initialization status of the instance that is to be discarded, invokes its uninitialization, and falsifies the initialization status. In order to encourage the use of assertInitialized and assertUninitialized they are dynamically bound to a static, always-failing assert and an empty/undefined function respectively.

    Returns MethodDecorator

Static initialize

  • initialize(): MethodDecorator
  • Method decorator for initialization of Initializable inheritors. This decorator asserts the initialization status of the instance that is to be initialized, invokes its initialization with arbitrary number of parameters, and sets the initialization status to the initialization success (either false or true). In order to encourage the use of assertInitialized and assertUninitialized they are dynamically bound to either a static, always-failing assert or an empty/undefined function.

    Returns MethodDecorator

Static uninitialize

  • uninitialize(): MethodDecorator
  • Method decorator for uninitialization of Initializable inheritors. This decorator asserts the initialization status of the instance that is to be uninitialized, invokes its uninitialization, and falsifies the initialization status. In order to encourage the use of assertInitialized and assertUninitialized they are dynamically bound to a static, always-failing assert and an empty/undefined function respectively.

    Returns MethodDecorator