Blender
V5.0
source
blender
nodes
composite
nodes
node_composite_invert.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
8
9
#include "
BLI_math_vector.hh
"
10
#include "
BLI_math_vector_types.hh
"
11
12
#include "
FN_multi_function_builder.hh
"
13
14
#include "
NOD_multi_function.hh
"
15
16
#include "
UI_resources.hh
"
17
18
#include "
GPU_material.hh
"
19
20
#include "
node_composite_util.hh
"
21
22
/* **************** INVERT ******************** */
23
24
namespace
blender::nodes::node_composite_invert_cc
{
25
26
static
void
cmp_node_invert_declare
(
NodeDeclarationBuilder
&
b
)
27
{
28
b
.use_custom_socket_order();
29
b
.allow_any_socket_order();
30
b
.is_function_node();
31
b
.add_input<
decl::Color
>(
"Color"
).default_value({1.0f, 1.0f, 1.0f, 1.0f}).hide_value();
32
b
.add_output<
decl::Color
>(
"Color"
).align_with_previous();
33
34
b
.add_input<
decl::Float
>(
"Factor"
,
"Fac"
)
35
.default_value(1.0f)
36
.min(0.0f)
37
.max(1.0f)
38
.
subtype
(
PROP_FACTOR
);
39
b
.add_input<
decl::Bool
>(
"Invert Color"
).default_value(
true
);
40
b
.add_input<
decl::Bool
>(
"Invert Alpha"
).default_value(
false
);
41
}
42
43
using namespace
blender::compositor
;
44
45
static
int
node_gpu_material
(
GPUMaterial
*material,
46
bNode
*node,
47
bNodeExecData
*
/*execdata*/
,
48
GPUNodeStack
*
inputs
,
49
GPUNodeStack
*
outputs
)
50
{
51
return
GPU_stack_link
(material, node,
"node_composite_invert"
,
inputs
,
outputs
);
52
}
53
54
static
void
node_build_multi_function
(
blender::nodes::NodeMultiFunctionBuilder
&builder)
55
{
56
static
auto
function = mf::build::SI4_SO<float4, float, bool, bool, float4>(
57
"Invert Color"
,
58
[](
const
float4
&
color
,
const
float
factor,
const
bool
invert_color,
const
bool
invert_alpha)
59
->
float4
{
60
float4
result
=
color
;
61
if
(invert_color) {
62
result
=
float4
(1.0f -
result
.xyz(),
result
.w);
63
}
64
if
(invert_alpha) {
65
result
=
float4
(
result
.xyz(), 1.0f -
result
.w);
66
}
67
return
math::interpolate
(
color
,
result
, factor);
68
},
69
mf::build::exec_presets::SomeSpanOrSingle<0>());
70
builder.
set_matching_fn
(function);
71
}
72
73
}
// namespace blender::nodes::node_composite_invert_cc
74
75
static
void
register_node_type_cmp_invert
()
76
{
77
namespace
file_ns =
blender::nodes::node_composite_invert_cc
;
78
79
static
blender::bke::bNodeType
ntype;
80
81
cmp_node_type_base
(&ntype,
"CompositorNodeInvert"
,
CMP_NODE_INVERT
);
82
ntype.
ui_name
=
"Invert Color"
;
83
ntype.
ui_description
=
"Invert colors, producing a negative"
;
84
ntype.
enum_name_legacy
=
"INVERT"
;
85
ntype.
nclass
=
NODE_CLASS_OP_COLOR
;
86
ntype.
declare
= file_ns::cmp_node_invert_declare;
87
ntype.
gpu_fn
= file_ns::node_gpu_material;
88
ntype.
build_multi_function
= file_ns::node_build_multi_function;
89
90
blender::bke::node_register_type
(ntype);
91
}
92
NOD_REGISTER_NODE
(
register_node_type_cmp_invert
)
NODE_CLASS_OP_COLOR
#define NODE_CLASS_OP_COLOR
Definition
BKE_node.hh:449
CMP_NODE_INVERT
#define CMP_NODE_INVERT
Definition
BKE_node_legacy_types.hh:200
result
double result
Definition
BLI_expr_pylike_eval_test.cc:351
BLI_math_vector.hh
BLI_math_vector_types.hh
FN_multi_function_builder.hh
GPU_material.hh
GPU_stack_link
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
Definition
gpu_node_graph.cc:851
NOD_multi_function.hh
NOD_REGISTER_NODE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
Definition
NOD_register.hh:34
PROP_FACTOR
@ PROP_FACTOR
Definition
RNA_types.hh:251
UI_resources.hh
blender::nodes::NodeDeclarationBuilder
Definition
NOD_node_declaration.hh:664
blender::nodes::NodeMultiFunctionBuilder
Definition
NOD_multi_function.hh:18
blender::nodes::NodeMultiFunctionBuilder::set_matching_fn
void set_matching_fn(const mf::MultiFunction *fn)
Definition
NOD_multi_function.hh:99
blender::nodes::decl::Bool
Definition
NOD_socket_declarations.hh:117
blender::nodes::decl::Color
Definition
NOD_socket_declarations.hh:139
blender::nodes::decl::Float
Definition
NOD_socket_declarations.hh:25
blender::nodes::decl::Float::subtype
PropertySubType subtype
Definition
NOD_socket_declarations.hh:32
b
b
Definition
compositor_morphological_distance_infos.hh:24
blender::bke::node_register_type
void node_register_type(bNodeType &ntype)
Definition
node.cc:2416
blender::color
Definition
BLI_color.hh:32
blender::compositor
Definition
BKE_node.hh:77
blender::math::interpolate
T interpolate(const T &a, const T &b, const FactorT &t)
Definition
BLI_math_base.hh:274
blender::nodes::node_composite_invert_cc
Definition
node_composite_invert.cc:24
blender::nodes::node_composite_invert_cc::node_build_multi_function
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
Definition
node_composite_invert.cc:54
blender::nodes::node_composite_invert_cc::cmp_node_invert_declare
static void cmp_node_invert_declare(NodeDeclarationBuilder &b)
Definition
node_composite_invert.cc:26
blender::nodes::node_composite_invert_cc::node_gpu_material
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
Definition
node_composite_invert.cc:45
blender::float4
VecBase< float, 4 > float4
Definition
BLI_math_vector_types.hh:620
register_node_type_cmp_invert
static void register_node_type_cmp_invert()
Definition
node_composite_invert.cc:75
cmp_node_type_base
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
Definition
node_composite_util.cc:33
node_composite_util.hh
outputs
static blender::bke::bNodeSocketTemplate outputs[]
Definition
node_texture_at.cc:16
inputs
static blender::bke::bNodeSocketTemplate inputs[]
Definition
node_texture_at.cc:11
GPUMaterial
Definition
gpu/intern/gpu_material.cc:63
GPUNodeStack
Definition
GPU_material.hh:295
bNodeExecData
Definition
node_util.hh:22
bNode
Definition
DNA_node_types.h:422
blender::bke::bNodeType
Defines a node type.
Definition
BKE_node.hh:238
blender::bke::bNodeType::ui_description
std::string ui_description
Definition
BKE_node.hh:244
blender::bke::bNodeType::ui_name
std::string ui_name
Definition
BKE_node.hh:243
blender::bke::bNodeType::gpu_fn
NodeGPUExecFunction gpu_fn
Definition
BKE_node.hh:342
blender::bke::bNodeType::build_multi_function
NodeMultiFunctionBuildFunction build_multi_function
Definition
BKE_node.hh:351
blender::bke::bNodeType::nclass
short nclass
Definition
BKE_node.hh:251
blender::bke::bNodeType::enum_name_legacy
const char * enum_name_legacy
Definition
BKE_node.hh:247
blender::bke::bNodeType::declare
NodeDeclareFunction declare
Definition
BKE_node.hh:362
Generated on
for Blender by
doxygen
1.16.1