RDPipelineColorBlendStateAttachment
继承: RefCounted
< Object
Pipeline color blend state attachment (used by RenderingDevice
).
描述
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
属性
方法
void | set_as_mix ( ) |
属性说明
BlendOperation alpha_blend_op = 0
void
set_alpha_blend_op ( value: BlendOperation )- BlendOperation get_alpha_blend_op ( )
The blend mode to use for the alpha channel.
BlendOperation color_blend_op = 0
void
set_color_blend_op ( value: BlendOperation )- BlendOperation get_color_blend_op ( )
The blend mode to use for the red/green/blue color channels.
BlendFactor dst_alpha_blend_factor = 0
void
set_dst_alpha_blend_factor ( value: BlendFactor )- BlendFactor get_dst_alpha_blend_factor ( )
Controls how the blend factor for the alpha channel is determined based on the destination's fragments.
BlendFactor dst_color_blend_factor = 0
void
set_dst_color_blend_factor ( value: BlendFactor )- BlendFactor get_dst_color_blend_factor ( )
Controls how the blend factor for the color channels is determined based on the destination's fragments.
bool
enable_blend = false
If true
, performs blending between the source and destination according to the factors defined in src_color_blend_factor
, dst_color_blend_factor
, src_alpha_blend_factor
and dst_alpha_blend_factor
. The blend modes color_blend_op
and alpha_blend_op
are also taken into account, with write_r
, write_g
, write_b
and write_a
controlling the output.
BlendFactor src_alpha_blend_factor = 0
void
set_src_alpha_blend_factor ( value: BlendFactor )- BlendFactor get_src_alpha_blend_factor ( )
Controls how the blend factor for the alpha channel is determined based on the source's fragments.
BlendFactor src_color_blend_factor = 0
void
set_src_color_blend_factor ( value: BlendFactor )- BlendFactor get_src_color_blend_factor ( )
Controls how the blend factor for the color channels is determined based on the source's fragments.
bool
write_a = true
If true
, writes the new alpha channel to the final result.
bool
write_b = true
If true
, writes the new blue color channel to the final result.
bool
write_g = true
If true
, writes the new green color channel to the final result.
bool
write_r = true
If true
, writes the new red color channel to the final result.
方法说明
void
set_as_mix ( )
Convenience method to perform standard mix blending with straight (non-premultiplied) alpha. This sets enable_blend
to true
, src_color_blend_factor
to RenderingDevice.BLEND_FACTOR_SRC_ALPHA
, dst_color_blend_factor
to RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
, src_alpha_blend_factor
to RenderingDevice.BLEND_FACTOR_SRC_ALPHA
and dst_alpha_blend_factor
to RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。