Blender
V5.0
source
blender
nodes
composite
nodes
node_composite_normal.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 "
BKE_node_runtime.hh
"
15
16
#include "
NOD_multi_function.hh
"
17
18
#include "
GPU_material.hh
"
19
20
#include "
node_composite_util.hh
"
21
22
/* **************** NORMAL ******************** */
23
24
namespace
blender::nodes::node_composite_normal_cc
{
25
26
static
void
cmp_node_normal_declare
(
NodeDeclarationBuilder
&
b
)
27
{
28
b
.is_function_node();
29
b
.add_output<
decl::Vector
>(
"Normal"
)
30
.default_value({0.0f, 0.0f, 1.0f})
31
.
min
(-1.0f)
32
.max(1.0f)
33
.
subtype
(
PROP_DIRECTION
);
34
}
35
36
using namespace
blender::compositor
;
37
38
/* The vector value is stored in the default value of the output socket. */
39
static
float3
get_normal
(
const
bNode
&node)
40
{
41
const
bNodeSocket
&normal_output = *node.output_by_identifier(
"Normal"
);
42
const
float3
node_normal = normal_output.default_value_typed<
bNodeSocketValueVector
>()->value;
43
return
math::normalize
(node_normal);
44
}
45
46
static
int
node_gpu_material
(
GPUMaterial
*material,
47
bNode
*node,
48
bNodeExecData
*
/*execdata*/
,
49
GPUNodeStack
*
/*inputs*/
,
50
GPUNodeStack
*
outputs
)
51
{
52
const
float3
normal =
get_normal
(*node);
53
return
GPU_link
(material,
"set_vector"
,
GPU_uniform
(normal), &
outputs
->link);
54
}
55
56
static
void
node_build_multi_function
(
blender::nodes::NodeMultiFunctionBuilder
&builder)
57
{
58
const
float3
normal =
get_normal
(builder.
node
());
59
builder.
construct_and_set_matching_fn
<mf::CustomMF_Constant<float3>>(normal);
60
}
61
62
}
// namespace blender::nodes::node_composite_normal_cc
63
64
static
void
register_node_type_cmp_normal
()
65
{
66
namespace
file_ns =
blender::nodes::node_composite_normal_cc
;
67
68
static
blender::bke::bNodeType
ntype;
69
70
cmp_node_type_base
(&ntype,
"CompositorNodeNormal"
,
CMP_NODE_NORMAL
);
71
ntype.
ui_name
=
"Normal"
;
72
ntype.
ui_description
=
"Input normalized normal values to other nodes in the tree"
;
73
ntype.
enum_name_legacy
=
"NORMAL"
;
74
ntype.
nclass
=
NODE_CLASS_INPUT
;
75
ntype.
declare
= file_ns::cmp_node_normal_declare;
76
ntype.
gpu_fn
= file_ns::node_gpu_material;
77
ntype.
build_multi_function
= file_ns::node_build_multi_function;
78
79
blender::bke::node_register_type
(ntype);
80
}
81
NOD_REGISTER_NODE
(
register_node_type_cmp_normal
)
NODE_CLASS_INPUT
#define NODE_CLASS_INPUT
Definition
BKE_node.hh:447
CMP_NODE_NORMAL
#define CMP_NODE_NORMAL
Definition
BKE_node_legacy_types.hh:155
BKE_node_runtime.hh
BLI_math_vector.hh
BLI_math_vector_types.hh
FN_multi_function_builder.hh
GPU_material.hh
GPU_link
bool GPU_link(GPUMaterial *mat, const char *name,...)
Definition
gpu_node_graph.cc:744
GPU_uniform
GPUNodeLink * GPU_uniform(const float *num)
Definition
gpu_node_graph.cc:661
NOD_multi_function.hh
NOD_REGISTER_NODE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
Definition
NOD_register.hh:34
PROP_DIRECTION
@ PROP_DIRECTION
Definition
RNA_types.hh:262
blender::nodes::NodeDeclarationBuilder
Definition
NOD_node_declaration.hh:664
blender::nodes::NodeMultiFunctionBuilder
Definition
NOD_multi_function.hh:18
blender::nodes::NodeMultiFunctionBuilder::node
const bNode & node()
Definition
NOD_multi_function.hh:84
blender::nodes::NodeMultiFunctionBuilder::construct_and_set_matching_fn
void construct_and_set_matching_fn(Args &&...args)
Definition
NOD_multi_function.hh:110
blender::nodes::decl::Vector
Definition
NOD_socket_declarations.hh:83
blender::nodes::decl::Vector::subtype
PropertySubType subtype
Definition
NOD_socket_declarations.hh:91
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::compositor
Definition
BKE_node.hh:77
blender::math::normalize
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
Definition
BLI_math_matrix.hh:778
blender::nodes::node_composite_normal_cc
Definition
node_composite_normal.cc:24
blender::nodes::node_composite_normal_cc::node_build_multi_function
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
Definition
node_composite_normal.cc:56
blender::nodes::node_composite_normal_cc::cmp_node_normal_declare
static void cmp_node_normal_declare(NodeDeclarationBuilder &b)
Definition
node_composite_normal.cc:26
blender::nodes::node_composite_normal_cc::node_gpu_material
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *, GPUNodeStack *outputs)
Definition
node_composite_normal.cc:46
blender::nodes::node_composite_normal_cc::get_normal
static float3 get_normal(const bNode &node)
Definition
node_composite_normal.cc:39
blender::float3
VecBase< float, 3 > float3
Definition
BLI_math_vector_types.hh:619
register_node_type_cmp_normal
static void register_node_type_cmp_normal()
Definition
node_composite_normal.cc:64
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
min
#define min(a, b)
Definition
sort.cc:36
GPUMaterial
Definition
gpu/intern/gpu_material.cc:63
GPUNodeStack
Definition
GPU_material.hh:295
bNodeExecData
Definition
node_util.hh:22
bNodeSocketValueVector
Definition
DNA_node_types.h:997
bNodeSocket
Definition
DNA_node_types.h:121
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