RDPipelineColorBlendStateAttachment

继承: RefCounted < Object

管道颜色混合状态附件(由RenderingDevice使用)。

描述

控制在使用 RenderingDevice 时,源片段与目标片段之间的混合是如何执行的。

作为参考,以下是常见的面向用户的混合模式在i3D的2D渲染器中的实现方式:

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

添加:

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

预乘

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 🔗

用于alpha通道的混合模式。


BlendOperation color_blend_op = 0 🔗

用于红色/绿色/蓝色通道的混合模式。


BlendFactor dst_alpha_blend_factor = 0 🔗

控制如何根据目标的片段确定alpha通道的混合因子。


BlendFactor dst_color_blend_factor = 0 🔗

控制如何根据目标片段确定颜色通道的混合因子。


bool enable_blend = false 🔗

  • void set_enable_blend(value: bool)

  • bool get_enable_blend()

如果true,则根据src_color_blend_factordst_color_blend_factorsrc_alpha_blend_factordst_alpha_blend_factor中定义的因素在源和目标之间进行混合。混合模式color_blend_opalpha_blend_op也被考虑在内,由write_rwrite_gwrite_bwrite_a控制输出。


BlendFactor src_alpha_blend_factor = 0 🔗

控制如何根据源片段确定alpha通道的混合因子。


BlendFactor src_color_blend_factor = 0 🔗

控制如何根据源片段确定颜色通道的混合因子。


bool write_a = true 🔗

  • void set_write_a(value: bool)

  • bool get_write_a()

如果true,则将新的alpha通道写入最终结果。


bool write_b = true 🔗

  • void set_write_b(value: bool)

  • bool get_write_b()

如果true,则将新的蓝色通道写入最终结果。


bool write_g = true 🔗

  • void set_write_g(value: bool)

  • bool get_write_g()

如果true,则将新的绿色通道写入最终结果。


bool write_r = true 🔗

  • void set_write_r(value: bool)

  • bool get_write_r()

如果true,则将新的红色通道写入最终结果。


方法说明

void set_as_mix() 🔗

使用直(非预乘)alpha执行标准混合混合的便捷方法。这将enable_blend设置为truesrc_color_blend_factor设置为RenderingDevice.BLEND_FACTOR_SRC_ALPHAdst_color_blend_factor设置为RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHAsrc_alpha_blend_factor设置为RenderingDevice.BLEND_FACTOR_SRC_ALPHAdst_alpha_blend_factor设置为RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA