2020-04-20 02:19:21 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2022-02-14 13:18:53 +00:00
<class name= "RDPipelineColorBlendStateAttachment" inherits= "RefCounted" version= "4.0" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2020-04-20 02:19:21 +00:00
<brief_description >
2023-03-28 15:32:29 +00:00
Pipeline color blend state attachment (used by [RenderingDevice]).
2020-04-20 02:19:21 +00:00
</brief_description>
<description >
2023-03-28 15:32:29 +00:00
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:
[b]Mix:[/b]
[codeblock]
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
[/codeblock]
[b]Add:[/b]
[codeblock]
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
[/codeblock]
[b]Subtract:[/b]
[codeblock]
var attachment = RDPipelineColorBlendStateAttachment.new()
attachment.enable_blend = true
attachment.alpha_blend_op = RenderingDevice.BLEND_OP_SUBTRACT
attachment.color_blend_op = RenderingDevice.BLEND_OP_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
[/codeblock]
[b]Multiply:[/b]
[codeblock]
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
[/codeblock]
[b]Pre-multiplied alpha:[/b]
[codeblock]
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
[/codeblock]
2020-04-20 02:19:21 +00:00
</description>
<tutorials >
</tutorials>
<methods >
2020-04-24 15:43:10 +00:00
<method name= "set_as_mix" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2020-04-24 15:43:10 +00:00
<description >
2023-03-28 15:32:29 +00:00
Convenience method to perform standard mix blending with straight (non-premultiplied) alpha. This sets [member enable_blend] to [code]true[/code], [member src_color_blend_factor] to [constant RenderingDevice.BLEND_FACTOR_SRC_ALPHA], [member dst_color_blend_factor] to [constant RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA], [member src_alpha_blend_factor] to [constant RenderingDevice.BLEND_FACTOR_SRC_ALPHA] and [member dst_alpha_blend_factor] to [constant RenderingDevice.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA].
2020-04-24 15:43:10 +00:00
</description>
</method>
2020-04-20 02:19:21 +00:00
</methods>
<members >
<member name= "alpha_blend_op" type= "int" setter= "set_alpha_blend_op" getter= "get_alpha_blend_op" enum= "RenderingDevice.BlendOperation" default= "0" >
2023-03-28 15:32:29 +00:00
The blend mode to use for the alpha channel.
2020-04-20 02:19:21 +00:00
</member>
<member name= "color_blend_op" type= "int" setter= "set_color_blend_op" getter= "get_color_blend_op" enum= "RenderingDevice.BlendOperation" default= "0" >
2023-03-28 15:32:29 +00:00
The blend mode to use for the red/green/blue color channels.
2020-04-20 02:19:21 +00:00
</member>
<member name= "dst_alpha_blend_factor" type= "int" setter= "set_dst_alpha_blend_factor" getter= "get_dst_alpha_blend_factor" enum= "RenderingDevice.BlendFactor" default= "0" >
2023-03-28 15:32:29 +00:00
Controls how the blend factor for the alpha channel is determined based on the destination's fragments.
2020-04-20 02:19:21 +00:00
</member>
<member name= "dst_color_blend_factor" type= "int" setter= "set_dst_color_blend_factor" getter= "get_dst_color_blend_factor" enum= "RenderingDevice.BlendFactor" default= "0" >
2023-03-28 15:32:29 +00:00
Controls how the blend factor for the color channels is determined based on the destination's fragments.
2020-04-20 02:19:21 +00:00
</member>
<member name= "enable_blend" type= "bool" setter= "set_enable_blend" getter= "get_enable_blend" default= "false" >
2023-03-28 15:32:29 +00:00
If [code]true[/code], performs blending between the source and destination according to the factors defined in [member src_color_blend_factor], [member dst_color_blend_factor], [member src_alpha_blend_factor] and [member dst_alpha_blend_factor]. The blend modes [member color_blend_op] and [member alpha_blend_op] are also taken into account, with [member write_r], [member write_g], [member write_b] and [member write_a] controlling the output.
2020-04-20 02:19:21 +00:00
</member>
<member name= "src_alpha_blend_factor" type= "int" setter= "set_src_alpha_blend_factor" getter= "get_src_alpha_blend_factor" enum= "RenderingDevice.BlendFactor" default= "0" >
2023-03-28 15:32:29 +00:00
Controls how the blend factor for the alpha channel is determined based on the source's fragments.
2020-04-20 02:19:21 +00:00
</member>
<member name= "src_color_blend_factor" type= "int" setter= "set_src_color_blend_factor" getter= "get_src_color_blend_factor" enum= "RenderingDevice.BlendFactor" default= "0" >
2023-03-28 15:32:29 +00:00
Controls how the blend factor for the color channels is determined based on the source's fragments.
2020-04-20 02:19:21 +00:00
</member>
<member name= "write_a" type= "bool" setter= "set_write_a" getter= "get_write_a" default= "true" >
2023-03-28 15:32:29 +00:00
If [code]true[/code], writes the new alpha channel to the final result.
2020-04-20 02:19:21 +00:00
</member>
<member name= "write_b" type= "bool" setter= "set_write_b" getter= "get_write_b" default= "true" >
2023-03-28 15:32:29 +00:00
If [code]true[/code], writes the new blue color channel to the final result.
2020-04-20 02:19:21 +00:00
</member>
<member name= "write_g" type= "bool" setter= "set_write_g" getter= "get_write_g" default= "true" >
2023-03-28 15:32:29 +00:00
If [code]true[/code], writes the new green color channel to the final result.
2020-04-20 02:19:21 +00:00
</member>
<member name= "write_r" type= "bool" setter= "set_write_r" getter= "get_write_r" default= "true" >
2023-03-28 15:32:29 +00:00
If [code]true[/code], writes the new red color channel to the final result.
2020-04-20 02:19:21 +00:00
</member>
</members>
</class>