Compositor: Implement Set Alpha for new CPU compositor
Reference #125968.
This commit is contained in:
@@ -54,6 +54,11 @@ static void node_composit_buts_set_alpha(uiLayout *layout, bContext * /*C*/, Poi
|
||||
|
||||
using namespace blender::realtime_compositor;
|
||||
|
||||
static CMPNodeSetAlphaMode get_mode(const bNode &node)
|
||||
{
|
||||
return static_cast<CMPNodeSetAlphaMode>(node_storage(node).mode);
|
||||
}
|
||||
|
||||
class SetAlphaShaderNode : public ShaderNode {
|
||||
public:
|
||||
using ShaderNode::ShaderNode;
|
||||
@@ -63,7 +68,7 @@ class SetAlphaShaderNode : public ShaderNode {
|
||||
GPUNodeStack *inputs = get_inputs_array();
|
||||
GPUNodeStack *outputs = get_outputs_array();
|
||||
|
||||
if (node_storage(bnode()).mode == CMP_NODE_SETALPHA_MODE_APPLY) {
|
||||
if (get_mode(bnode()) == CMP_NODE_SETALPHA_MODE_APPLY) {
|
||||
GPU_stack_link(material, &bnode(), "node_composite_set_alpha_apply", inputs, outputs);
|
||||
return;
|
||||
}
|
||||
@@ -79,12 +84,24 @@ static ShaderNode *get_compositor_shader_node(DNode node)
|
||||
|
||||
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
|
||||
{
|
||||
/* Not yet implemented. Return zero. */
|
||||
static auto function = mf::build::SI2_SO<float4, float, float4>(
|
||||
"Set Alpha",
|
||||
[](const float4 & /*color*/, const float /*alpha*/) -> float4 { return float4(0.0f); },
|
||||
static auto apply_function = mf::build::SI2_SO<float4, float, float4>(
|
||||
"Set Alpha Apply",
|
||||
[](const float4 &color, const float alpha) -> float4 { return color * alpha; },
|
||||
mf::build::exec_presets::AllSpanOrSingle());
|
||||
builder.set_matching_fn(function);
|
||||
|
||||
static auto replace_function = mf::build::SI2_SO<float4, float, float4>(
|
||||
"Set Alpha Replace",
|
||||
[](const float4 &color, const float alpha) -> float4 { return float4(color.xyz(), alpha); },
|
||||
mf::build::exec_presets::AllSpanOrSingle());
|
||||
|
||||
switch (get_mode(builder.node())) {
|
||||
case CMP_NODE_SETALPHA_MODE_APPLY:
|
||||
builder.set_matching_fn(apply_function);
|
||||
break;
|
||||
case CMP_NODE_SETALPHA_MODE_REPLACE_ALPHA:
|
||||
builder.set_matching_fn(replace_function);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace blender::nodes::node_composite_setalpha_cc
|
||||
|
||||
Reference in New Issue
Block a user