RDPipelineColorBlendStateAttachment
继承: RefCounted < Object
管线颜色混合状态附件(由 RenderingDevice 使用)。
描述
控制使用 RenderingDevice 时如何在来源和目标片段之间进行混合。
以下是常见面向用户的混合模式在 Godot 的 2D 渲染器中的实现方法,仅供参考:
混合:
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
加:
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
减:
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
乘:
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
预乘 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 |
属性说明
BlendOperation alpha_blend_op = 0
🔗
void set_alpha_blend_op(value: BlendOperation)
BlendOperation get_alpha_blend_op()
Alpha 通道使用的混合模式。
BlendOperation color_blend_op = 0
🔗
void set_color_blend_op(value: BlendOperation)
BlendOperation get_color_blend_op()
红、绿、蓝通道使用的混合模式。
BlendFactor dst_alpha_blend_factor = 0
🔗
void set_dst_alpha_blend_factor(value: BlendFactor)
BlendFactor get_dst_alpha_blend_factor()
控制如何根据目标片段确定 Alpha 通道的混合系数。
BlendFactor dst_color_blend_factor = 0
🔗
void set_dst_color_blend_factor(value: BlendFactor)
BlendFactor get_dst_color_blend_factor()
控制如何根据目标片段确定颜色通道的混合系数。
如果为 true
,则会根据 src_color_blend_factor、dst_color_blend_factor、src_alpha_blend_factor 和 dst_alpha_blend_factor 中定义的系数对来源和目标进行混合。同时也会考虑 color_blend_op 和 alpha_blend_op 混合模式,write_r、write_g、write_b 和 write_a 则控制的是输出。
BlendFactor src_alpha_blend_factor = 0
🔗
void set_src_alpha_blend_factor(value: BlendFactor)
BlendFactor get_src_alpha_blend_factor()
控制如何根据来源片段确定 Alpha 通道的混合系数。
BlendFactor src_color_blend_factor = 0
🔗
void set_src_color_blend_factor(value: BlendFactor)
BlendFactor get_src_color_blend_factor()
控制如何根据来源片段确定颜色通道的混合系数。
如果为 true
,则将新的 Alpha 通道写入最终结果。
如果为 true
,则将新的蓝色通道写入最终结果。
如果为 true
,则将新的绿色通道写入最终结果。
如果为 true
,则将新的红色通道写入最终结果。
方法说明
void set_as_mix() 🔗
使用普通(非预乘)Alpha 进行标准混合混合(mix blending)的简便方法。这个方法会将 enable_blend 设为 true
,将 src_color_blend_factor 设为 RenderingDevice.BLEND_FACTOR_SRC_ALPHA,将 dst_color_blend_factor 设为 RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,将 src_alpha_blend_factor 设为 RenderingDevice.BLEND_FACTOR_SRC_ALPHA,将 dst_alpha_blend_factor 设为 RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA。