Blender V4.3
node_composite_setalpha.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2006 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "UI_interface.hh"
10#include "UI_resources.hh"
11
12#include "GPU_material.hh"
13
14#include "COM_shader_node.hh"
15
17
18/* **************** SET ALPHA ******************** */
19
21
23
25{
26 b.add_input<decl::Color>("Image")
27 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
28 .compositor_domain_priority(0);
29 b.add_input<decl::Float>("Alpha")
30 .default_value(1.0f)
31 .min(0.0f)
32 .max(1.0f)
34 b.add_output<decl::Color>("Image");
35}
36
37static void node_composit_init_setalpha(bNodeTree * /*ntree*/, bNode *node)
38{
39 NodeSetAlpha *settings = MEM_cnew<NodeSetAlpha>(__func__);
40 node->storage = settings;
41 settings->mode = CMP_NODE_SETALPHA_MODE_APPLY;
42}
43
45{
46 uiItemR(layout, ptr, "mode", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
47}
48
49using namespace blender::realtime_compositor;
50
52 public:
54
55 void compile(GPUMaterial *material) override
56 {
59
60 if (node_storage(bnode()).mode == CMP_NODE_SETALPHA_MODE_APPLY) {
61 GPU_stack_link(material, &bnode(), "node_composite_set_alpha_apply", inputs, outputs);
62 return;
63 }
64
65 GPU_stack_link(material, &bnode(), "node_composite_set_alpha_replace", inputs, outputs);
66 }
67};
68
70{
71 return new SetAlphaShaderNode(node);
72}
73
74} // namespace blender::nodes::node_composite_setalpha_cc
75
77{
79
80 static blender::bke::bNodeType ntype;
81
82 cmp_node_type_base(&ntype, CMP_NODE_SETALPHA, "Set Alpha", NODE_CLASS_CONVERTER);
83 ntype.declare = file_ns::cmp_node_setalpha_declare;
84 ntype.draw_buttons = file_ns::node_composit_buts_set_alpha;
85 ntype.initfunc = file_ns::node_composit_init_setalpha;
88 ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
89
91}
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:410
#define NODE_STORAGE_FUNCS(StorageT)
Definition BKE_node.hh:1799
@ CMP_NODE_SETALPHA_MODE_APPLY
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
local_group_size(16, 16) .push_constant(Type b
void node_type_storage(bNodeType *ntype, const char *storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
Definition node.cc:4632
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static ShaderNode * get_compositor_shader_node(DNode node)
static void node_composit_init_setalpha(bNodeTree *, bNode *node)
static void node_composit_buts_set_alpha(uiLayout *layout, bContext *, PointerRNA *ptr)
static void cmp_node_setalpha_declare(NodeDeclarationBuilder &b)
void register_node_type_cmp_setalpha()
void cmp_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void node_free_standard_storage(bNode *node)
Definition node_util.cc:46
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:58
Defines a node type.
Definition BKE_node.hh:218
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:267
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:238
NodeDeclareFunction declare
Definition BKE_node.hh:347
NodeGetCompositorShaderNodeFunction get_compositor_shader_node
Definition BKE_node.hh:328
PointerRNA * ptr
Definition wm_files.cc:4126