Blender V4.3
node_composite_distance_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 Distance Matte ********************************* */
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::Color>("Key Color")
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_distance_matte(bNodeTree * /*ntree*/, bNode *node)
37{
38 NodeChroma *c = MEM_cnew<NodeChroma>(__func__);
39 node->storage = c;
41 c->t1 = 0.1f;
42 c->t2 = 0.1f;
43}
44
46{
47 uiLayout *col, *row;
48
49 col = uiLayoutColumn(layout, true);
50
51 uiItemL(layout, IFACE_("Color Space:"), ICON_NONE);
52 row = uiLayoutRow(layout, false);
53 uiItemR(row, ptr, "channel", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
54
55 uiItemR(
56 col, ptr, "tolerance", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
57 uiItemR(col, ptr, "falloff", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
58}
59
60using namespace blender::realtime_compositor;
61
63 public:
65
66 void compile(GPUMaterial *material) override
67 {
70
71 const float tolerance = get_tolerance();
72 const float falloff = get_falloff();
73
75 GPU_stack_link(material,
76 &bnode(),
77 "node_composite_distance_matte_rgba",
78 inputs,
79 outputs,
80 GPU_uniform(&tolerance),
81 GPU_uniform(&falloff));
82 return;
83 }
84
85 GPU_stack_link(material,
86 &bnode(),
87 "node_composite_distance_matte_ycca",
88 inputs,
89 outputs,
90 GPU_uniform(&tolerance),
91 GPU_uniform(&falloff));
92 }
93
98
100 {
101 return node_storage(bnode()).t1;
102 }
103
105 {
106 return node_storage(bnode()).t2;
107 }
108};
109
111{
112 return new DistanceMatteShaderNode(node);
113}
114
115} // namespace blender::nodes::node_composite_distance_matte_cc
116
118{
120
121 static blender::bke::bNodeType ntype;
122
123 cmp_node_type_base(&ntype, CMP_NODE_DIST_MATTE, "Distance Key", NODE_CLASS_MATTE);
124 ntype.declare = file_ns::cmp_node_distance_matte_declare;
125 ntype.draw_buttons = file_ns::node_composit_buts_distance_matte;
126 ntype.flag |= NODE_PREVIEW;
127 ntype.initfunc = file_ns::node_composit_init_distance_matte;
130 ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
131
133}
#define NODE_CLASS_MATTE
Definition BKE_node.hh:411
#define NODE_STORAGE_FUNCS(StorageT)
Definition BKE_node.hh:1799
#define IFACE_(msgid)
@ NODE_PREVIEW
CMPNodeDistanceMatteColorSpace
@ CMP_NODE_DISTANCE_MATTE_COLOR_SPACE_RGBA
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_uniform(const float *num)
void uiItemL(uiLayout *layout, const char *name, int icon)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
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_EXPAND
@ 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 node_composit_init_distance_matte(bNodeTree *, bNode *node)
static void node_composit_buts_distance_matte(uiLayout *layout, bContext *, PointerRNA *ptr)
static void cmp_node_distance_matte_declare(NodeDeclarationBuilder &b)
void register_node_type_cmp_distance_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