Blender V4.3
node_composite_luma_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
10
11#include "UI_interface.hh"
12#include "UI_resources.hh"
13
14#include "GPU_material.hh"
15
16#include "COM_shader_node.hh"
17
19
20/* ******************* Luma Matte Node ********************************* */
21
23
25
27{
28 b.add_input<decl::Color>("Image")
29 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
30 .compositor_domain_priority(0);
31 b.add_output<decl::Color>("Image");
32 b.add_output<decl::Float>("Matte");
33}
34
35static void node_composit_init_luma_matte(bNodeTree * /*ntree*/, bNode *node)
36{
37 NodeChroma *c = MEM_cnew<NodeChroma>(__func__);
38 node->storage = c;
39 c->t1 = 1.0f;
40 c->t2 = 0.0f;
41}
42
44{
46
47 col = uiLayoutColumn(layout, true);
48 uiItemR(
49 col, ptr, "limit_max", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
50 uiItemR(
51 col, ptr, "limit_min", 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 high = get_high();
66 const float low = get_low();
67 float luminance_coefficients[3];
69
70 GPU_stack_link(material,
71 &bnode(),
72 "node_composite_luminance_matte",
73 inputs,
74 outputs,
75 GPU_uniform(&high),
76 GPU_uniform(&low),
77 GPU_constant(luminance_coefficients));
78 }
79
80 float get_high()
81 {
82 return node_storage(bnode()).t1;
83 }
84
85 float get_low()
86 {
87 return node_storage(bnode()).t2;
88 }
89};
90
92{
93 return new LuminanceMatteShaderNode(node);
94}
95
96} // namespace blender::nodes::node_composite_luma_matte_cc
97
99{
101
102 static blender::bke::bNodeType ntype;
103
104 cmp_node_type_base(&ntype, CMP_NODE_LUMA_MATTE, "Luminance Key", NODE_CLASS_MATTE);
105 ntype.declare = file_ns::cmp_node_luma_matte_declare;
106 ntype.draw_buttons = file_ns::node_composit_buts_luma_matte;
107 ntype.flag |= NODE_PREVIEW;
108 ntype.initfunc = file_ns::node_composit_init_luma_matte;
111 ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
112
114}
#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_constant(const float *num)
GPUNodeLink * GPU_uniform(const float *num)
BLI_INLINE void IMB_colormanagement_get_luminance_coefficients(float r_rgb[3])
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_luma_matte_declare(NodeDeclarationBuilder &b)
static void node_composit_buts_luma_matte(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_composit_init_luma_matte(bNodeTree *, bNode *node)
static ShaderNode * get_compositor_shader_node(DNode node)
void register_node_type_cmp_luma_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