Engine API Reference - v2.22.0-beta.8
    Preparing search index...

    Class BlendState

    BlendState is a descriptor that defines how output of fragment shader is written and blended into render target. A blend state can be set on a material using Material#blendState, or in some cases on the graphics device using GraphicsDevice#setBlendState.

    For the best performance, do not modify blend state after it has been created, but create multiple blend states and assign them to the material or graphics device as needed.

    By default the blend state applies to all color attachments of the render target. When multiple color attachments are used, individual attachments can be given an independent blend state using BlendState#setAttachment. This requires GraphicsDevice#supportsIndependentBlending - on devices without support, the state of the attachment 0 is used for all attachments.

    Index
    ADDBLEND: BlendState = ...

    A blend state that does simple additive blending.

    ALPHABLEND: BlendState = ...

    A blend state that does simple translucency using alpha channel.

    NOBLEND: BlendState = ...

    A blend state that has blending disabled and writes to all color channels.

    NOWRITE: BlendState = ...

    A blend state that does not write to color channels.

    • get blend(): boolean

      Gets whether blending is enabled.

      Returns boolean

    • set blend(value: boolean): void

      Sets whether blending is enabled.

      Parameters

      • value: boolean

      Returns void

    • get hasAttachmentOverrides(): boolean

      Gets whether any color attachment has been given an independent blend state using BlendState#setAttachment.

      Returns boolean

    • Removes the independent blend state of the specified color attachment, making it follow attachment 0 again.

      Parameters

      • index: number

        The index of the color attachment, in 1 to 7 range.

      Returns void

    • Returns an identical copy of the specified blend state.

      Returns BlendState

      The result of the cloning.

    • Copies the contents of a source blend state to this blend state.

      Parameters

      Returns BlendState

      Self for chaining.

    • Reports whether two BlendStates are equal.

      Parameters

      Returns boolean

      True if the blend states are equal and false otherwise.

    • Stores the blend state of the specified color attachment in the supplied blend state. When the attachment does not have an independent blend state, the state of attachment 0 is stored.

      Parameters

      • index: number

        The index of the color attachment, in 0 to 7 range.

      • dst: BlendState

        The blend state to store the result in. This avoids allocations, as a single instance can be reused.

      Returns BlendState

      The supplied dst, for chaining.

    • Assigns an independent blend state to the specified color attachment. The blend state of the supplied source is copied, and so subsequent changes to either the source or to attachment 0 do not affect it. An attachment which has not been assigned an independent state instead follows attachment 0.

      Note that this requires GraphicsDevice#supportsIndependentBlending - on devices without support, the state of attachment 0 is used for all attachments.

      Parameters

      • index: number

        The index of the color attachment, in 1 to 7 range. Attachment 0 is configured using the other functions and properties of this class.

      • src: BlendState | null

        The blend state to copy from, or null to make the attachment follow attachment 0 again.

      Returns void

      // attachment 1 keeps the blending of attachment 0, but does not write any channels
      const state = material.blendState.clone();
      const noWrite = state.clone();
      noWrite.setColorWrite(false, false, false, false);
      state.setAttachment(1, noWrite);