RDPipelineColorBlendStateAttachment

继承: RefCounted < Object

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

描述

控制使用 RenderingDevice 时如何在来源和目标片段之间进行混合。

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

混合:

  1. var attachment = RDPipelineColorBlendStateAttachment.new()
  2. attachment.enable_blend = true
  3. attachment.color_blend_op = RenderingDevice.BLEND_OP_ADD
  4. attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
  5. attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
  6. attachment.alpha_blend_op = RenderingDevice.BLEND_OP_ADD
  7. attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
  8. attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA

加:

  1. var attachment = RDPipelineColorBlendStateAttachment.new()
  2. attachment.enable_blend = true
  3. attachment.alpha_blend_op = RenderingDevice.BLEND_OP_ADD
  4. attachment.color_blend_op = RenderingDevice.BLEND_OP_ADD
  5. attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
  6. attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
  7. attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
  8. attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE

减:

  1. var attachment = RDPipelineColorBlendStateAttachment.new()
  2. attachment.enable_blend = true
  3. attachment.alpha_blend_op = RenderingDevice.BLEND_OP_REVERSE_SUBTRACT
  4. attachment.color_blend_op = RenderingDevice.BLEND_OP_REVERSE_SUBTRACT
  5. attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
  6. attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
  7. attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_SRC_ALPHA
  8. attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE

乘:

  1. var attachment = RDPipelineColorBlendStateAttachment.new()
  2. attachment.enable_blend = true
  3. attachment.alpha_blend_op = RenderingDevice.BLEND_OP_ADD
  4. attachment.color_blend_op = RenderingDevice.BLEND_OP_ADD
  5. attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_DST_COLOR
  6. attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ZERO
  7. attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_DST_ALPHA
  8. attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ZERO

预乘 Alpha:

  1. var attachment = RDPipelineColorBlendStateAttachment.new()
  2. attachment.enable_blend = true
  3. attachment.alpha_blend_op = RenderingDevice.BLEND_OP_ADD
  4. attachment.color_blend_op = RenderingDevice.BLEND_OP_ADD
  5. attachment.src_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
  6. attachment.dst_color_blend_factor = RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
  7. attachment.src_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE
  8. attachment.dst_alpha_blend_factor = RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA

属性

BlendOperation

alpha_blend_op

0

BlendOperation

color_blend_op

0

BlendFactor

dst_alpha_blend_factor

0

BlendFactor

dst_color_blend_factor

0

bool

enable_blend

false

BlendFactor

src_alpha_blend_factor

0

BlendFactor

src_color_blend_factor

0

bool

write_a

true

bool

write_b

true

bool

write_g

true

bool

write_r

true

方法

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 ( bool value )

  • 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 ( bool value )

  • bool get_write_a ( )

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


bool write_b = true

  • void set_write_b ( bool value )

  • bool get_write_b ( )

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


bool write_g = true

  • void set_write_g ( bool value )

  • bool get_write_g ( )

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


bool write_r = true

  • void set_write_r ( bool value )

  • bool get_write_r ( )

如果为 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

Previous Next


© 版权所有 2014-present Juan Linietsky, Ariel Manzur and the Godot community (CC BY 3.0). Revision b1c660f7.

Built with Sphinx using a theme provided by Read the Docs.