Blender V4.3
node_composite_diff_matte.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/* ******************* channel Difference Matte ********************************* */
19
21
23
25{
26 b.add_input<decl::Color>("Image 1")
27 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
28 .compositor_domain_priority(0);
29 b.add_input<decl::Color>("Image 2")
30 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
31 .compositor_domain_priority(1);
32 b.add_output<decl::Color>("Image");
33 b.add_output<decl::Float>("Matte");
34}
35
36static void node_composit_init_diff_matte(bNodeTree * /*ntree*/, bNode *node)
37{
38 NodeChroma *c = MEM_cnew<NodeChroma>(__func__);
39 node->storage = c;
40 c->t1 = 0.1f;
41 c->t2 = 0.1f;
42}
43
45{
47
48 col = uiLayoutColumn(layout, true);
49 uiItemR(
50 col, ptr, "tolerance", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
51 uiItemR(col, ptr, "falloff", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
52}
53
54using namespace blender::realtime_compositor;
55
57 public:
59
60 void compile(GPUMaterial *material) override
61 {
64
65 const float tolerance = get_tolerance();
66 const float falloff = get_falloff();
67
68 GPU_stack_link(material,
69 &bnode(),
70 "node_composite_difference_matte",
71 inputs,
72 outputs,
73 GPU_uniform(&tolerance),
74 GPU_uniform(&falloff));
75 }
76
78 {
79 return node_storage(bnode()).t1;
80 }
81
83 {
84 return node_storage(bnode()).t2;
85 }
86};
87
89{
90 return new DifferenceMatteShaderNode(node);
91}
92
93} // namespace blender::nodes::node_composite_diff_matte_cc
94
96{
98
99 static blender::bke::bNodeType ntype;
100
101 cmp_node_type_base(&ntype, CMP_NODE_DIFF_MATTE, "Difference Key", NODE_CLASS_MATTE);
102 ntype.declare = file_ns::cmp_node_diff_matte_declare;
103 ntype.draw_buttons = file_ns::node_composit_buts_diff_matte;
104 ntype.flag |= NODE_PREVIEW;
105 ntype.initfunc = file_ns::node_composit_init_diff_matte;
108 ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
109
111}
#define NODE_CLASS_MATTE
Definition BKE_node.hh:411
#define NODE_STORAGE_FUNCS(StorageT)
Definition BKE_node.hh:1799
@ NODE_PREVIEW
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_uniform(const float *num)
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
@ UI_ITEM_R_SLIDER
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 cmp_node_diff_matte_declare(NodeDeclarationBuilder &b)
static void node_composit_buts_diff_matte(uiLayout *layout, bContext *, PointerRNA *ptr)
static ShaderNode * get_compositor_shader_node(DNode node)
static void node_composit_init_diff_matte(bNodeTree *, bNode *node)
void register_node_type_cmp_diff_matte()
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