Table of Contents

Class RDPipelineColorBlendStateAttachment

Namespace
Godot
Assembly
GodotSharp.dll

Controls how blending between source and destination fragments is performed when using RenderingDevice.

For reference, this is how common user-facing blend modes are implemented in Godot's 2D renderer:

Mix:

var attachment = RDPipelineColorBlendStateAttachment.new()
  attachment.enable_blend = true
  attachment.color_blend_op = RenderingDevice.BLEND_OP_ADD
  attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
  attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
  attachment.alpha_blend_op = RenderingDevice.BLEND_OP_ADD
  attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
  attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA

Add:

var attachment = RDPipelineColorBlendStateAttachment.new()
  attachment.enable_blend = true
  attachment.alpha_blend_op = RenderingDevice.BLEND_OP_ADD
  attachment.color_blend_op = RenderingDevice.BLEND_OP_ADD
  attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
  attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
  attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
  attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE

Subtract:

var attachment = RDPipelineColorBlendStateAttachment.new()
  attachment.enable_blend = true
  attachment.alpha_blend_op = RenderingDevice.BLEND_OP_REVERSE_SUBTRACT
  attachment.color_blend_op = RenderingDevice.BLEND_OP_REVERSE_SUBTRACT
  attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
  attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
  attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
  attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE

Multiply:

var attachment = RDPipelineColorBlendStateAttachment.new()
  attachment.enable_blend = true
  attachment.alpha_blend_op = RenderingDevice.BLEND_OP_ADD
  attachment.color_blend_op = RenderingDevice.BLEND_OP_ADD
  attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_DST_COLOR
  attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ZERO
  attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_DST_ALPHA
  attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ZERO

Pre-multiplied alpha:

var attachment = RDPipelineColorBlendStateAttachment.new()
  attachment.enable_blend = true
  attachment.alpha_blend_op = RenderingDevice.BLEND_OP_ADD
  attachment.color_blend_op = RenderingDevice.BLEND_OP_ADD
  attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
  attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
  attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
  attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
public class RDPipelineColorBlendStateAttachment : RefCounted, IDisposable
Inheritance
RDPipelineColorBlendStateAttachment
Implements
Inherited Members

Constructors

RDPipelineColorBlendStateAttachment()

public RDPipelineColorBlendStateAttachment()

Properties

AlphaBlendOp

The blend mode to use for the alpha channel.

public RenderingDevice.BlendOperation AlphaBlendOp { get; set; }

Property Value

RenderingDevice.BlendOperation

ColorBlendOp

The blend mode to use for the red/green/blue color channels.

public RenderingDevice.BlendOperation ColorBlendOp { get; set; }

Property Value

RenderingDevice.BlendOperation

DstAlphaBlendFactor

Controls how the blend factor for the alpha channel is determined based on the destination's fragments.

public RenderingDevice.BlendFactor DstAlphaBlendFactor { get; set; }

Property Value

RenderingDevice.BlendFactor

DstColorBlendFactor

Controls how the blend factor for the color channels is determined based on the destination's fragments.

public RenderingDevice.BlendFactor DstColorBlendFactor { get; set; }

Property Value

RenderingDevice.BlendFactor

EnableBlend

If true, performs blending between the source and destination according to the factors defined in SrcColorBlendFactor, DstColorBlendFactor, SrcAlphaBlendFactor and DstAlphaBlendFactor. The blend modes ColorBlendOp and AlphaBlendOp are also taken into account, with WriteR, WriteG, WriteB and WriteA controlling the output.

public bool EnableBlend { get; set; }

Property Value

bool

SrcAlphaBlendFactor

Controls how the blend factor for the alpha channel is determined based on the source's fragments.

public RenderingDevice.BlendFactor SrcAlphaBlendFactor { get; set; }

Property Value

RenderingDevice.BlendFactor

SrcColorBlendFactor

Controls how the blend factor for the color channels is determined based on the source's fragments.

public RenderingDevice.BlendFactor SrcColorBlendFactor { get; set; }

Property Value

RenderingDevice.BlendFactor

WriteA

If true, writes the new alpha channel to the final result.

public bool WriteA { get; set; }

Property Value

bool

WriteB

If true, writes the new blue color channel to the final result.

public bool WriteB { get; set; }

Property Value

bool

WriteG

If true, writes the new green color channel to the final result.

public bool WriteG { get; set; }

Property Value

bool

WriteR

If true, writes the new red color channel to the final result.

public bool WriteR { get; set; }

Property Value

bool

Methods

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

SetAsMix()

Convenience method to perform standard mix blending with straight (non-premultiplied) alpha. This sets EnableBlend to true, SrcColorBlendFactor to SrcAlpha, DstColorBlendFactor to OneMinusSrcAlpha, SrcAlphaBlendFactor to SrcAlpha and DstAlphaBlendFactor to OneMinusSrcAlpha.

public void SetAsMix()