Blender V4.3
node_composite_alpha_over.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/* **************** ALPHAOVER ******************** */
19
21
23
25{
26 b.add_input<decl::Float>("Fac")
27 .default_value(1.0f)
28 .min(0.0f)
29 .max(1.0f)
31 .compositor_domain_priority(2);
32 b.add_input<decl::Color>("Image")
33 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
34 .compositor_domain_priority(0);
35 b.add_input<decl::Color>("Image", "Image_001")
36 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
37 .compositor_domain_priority(1);
38 b.add_output<decl::Color>("Image");
39}
40
41static void node_alphaover_init(bNodeTree * /*ntree*/, bNode *node)
42{
43 node->storage = MEM_cnew<NodeTwoFloats>(__func__);
44}
45
47{
49
50 col = uiLayoutColumn(layout, true);
51 uiItemR(col, ptr, "use_premultiply", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
52 uiItemR(col, ptr, "premul", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
53}
54
55using namespace blender::realtime_compositor;
56
58 public:
60
61 void compile(GPUMaterial *material) override
62 {
65
66 const float premultiply_factor = get_premultiply_factor();
67 if (premultiply_factor != 0.0f) {
68 GPU_stack_link(material,
69 &bnode(),
70 "node_composite_alpha_over_mixed",
71 inputs,
72 outputs,
73 GPU_uniform(&premultiply_factor));
74 return;
75 }
76
77 if (get_use_premultiply()) {
78 GPU_stack_link(material, &bnode(), "node_composite_alpha_over_key", inputs, outputs);
79 return;
80 }
81
82 GPU_stack_link(material, &bnode(), "node_composite_alpha_over_premultiply", inputs, outputs);
83 }
84
86 {
87 return bnode().custom1;
88 }
89
91 {
92 return node_storage(bnode()).x;
93 }
94};
95
97{
98 return new AlphaOverShaderNode(node);
99}
100
101} // namespace blender::nodes::node_composite_alpha_over_cc
102
104{
106
107 static blender::bke::bNodeType ntype;
108
109 cmp_node_type_base(&ntype, CMP_NODE_ALPHAOVER, "Alpha Over", NODE_CLASS_OP_COLOR);
110 ntype.declare = file_ns::cmp_node_alphaover_declare;
111 ntype.draw_buttons = file_ns::node_composit_buts_alphaover;
112 ntype.initfunc = file_ns::node_alphaover_init;
115 ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
116
118}
#define NODE_STORAGE_FUNCS(StorageT)
Definition BKE_node.hh:1799
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:406
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_uniform(const float *num)
@ PROP_FACTOR
Definition RNA_types.hh:154
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
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
uint col
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 void node_composit_buts_alphaover(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_alphaover_init(bNodeTree *, bNode *node)
static ShaderNode * get_compositor_shader_node(DNode node)
static void cmp_node_alphaover_declare(NodeDeclarationBuilder &b)
void register_node_type_cmp_alphaover()
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
int16_t custom1
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