Blender V4.3
node_composite_color_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/* ******************* Color 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_color_matte(bNodeTree * /*ntree*/, bNode *node)
37{
38 NodeChroma *c = MEM_cnew<NodeChroma>(__func__);
39 node->storage = c;
40 c->t1 = 0.01f;
41 c->t2 = 0.1f;
42 c->t3 = 0.1f;
43 c->fsize = 0.0f;
44 c->fstrength = 1.0f;
45}
46
48{
50
51 col = uiLayoutColumn(layout, true);
52 uiItemR(
53 col, ptr, "color_hue", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
55 ptr,
56 "color_saturation",
58 nullptr,
59 ICON_NONE);
60 uiItemR(
61 col, ptr, "color_value", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
62}
63
64using namespace blender::realtime_compositor;
65
67 public:
69
70 void compile(GPUMaterial *material) override
71 {
74
75 const float hue_epsilon = get_hue_epsilon();
76 const float saturation_epsilon = get_saturation_epsilon();
77 const float value_epsilon = get_value_epsilon();
78
79 GPU_stack_link(material,
80 &bnode(),
81 "node_composite_color_matte",
82 inputs,
83 outputs,
84 GPU_uniform(&hue_epsilon),
85 GPU_uniform(&saturation_epsilon),
86 GPU_uniform(&value_epsilon));
87 }
88
90 {
91 /* Divide by 2 because the hue wraps around. */
92 return node_storage(bnode()).t1 / 2.0f;
93 }
94
96 {
97 return node_storage(bnode()).t2;
98 }
99
101 {
102 return node_storage(bnode()).t3;
103 }
104};
105
107{
108 return new ColorMatteShaderNode(node);
109}
110
111} // namespace blender::nodes::node_composite_color_matte_cc
112
114{
116
117 static blender::bke::bNodeType ntype;
118
119 cmp_node_type_base(&ntype, CMP_NODE_COLOR_MATTE, "Color Key", NODE_CLASS_MATTE);
120 ntype.declare = file_ns::cmp_node_color_matte_declare;
121 ntype.draw_buttons = file_ns::node_composit_buts_color_matte;
122 ntype.flag |= NODE_PREVIEW;
123 ntype.initfunc = file_ns::node_composit_init_color_matte;
126 ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
127
129}
#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 node_composit_init_color_matte(bNodeTree *, bNode *node)
static void node_composit_buts_color_matte(uiLayout *layout, bContext *, PointerRNA *ptr)
static void cmp_node_color_matte_declare(NodeDeclarationBuilder &b)
void register_node_type_cmp_color_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