Blender
V4.3
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 "
GPU_material.hh
"
10
11
#include "
COM_shader_node.hh
"
12
13
#include "
node_composite_util.hh
"
14
15
/* **************** NORMAL ******************** */
16
17
namespace
blender::nodes::node_composite_normal_cc
{
18
19
static
void
cmp_node_normal_declare
(
NodeDeclarationBuilder
&
b
)
20
{
21
b
.add_input<
decl::Vector
>(
"Normal"
)
22
.default_value({0.0f, 0.0f, 1.0f})
23
.
min
(-1.0f)
24
.max(1.0f)
25
.
subtype
(
PROP_DIRECTION
)
26
.compositor_domain_priority(0);
27
b
.add_output<
decl::Vector
>(
"Normal"
)
28
.default_value({0.0f, 0.0f, 1.0f})
29
.
min
(-1.0f)
30
.max(1.0f)
31
.
subtype
(
PROP_DIRECTION
);
32
b
.add_output<
decl::Float
>(
"Dot"
);
33
}
34
35
using namespace
blender::realtime_compositor
;
36
37
class
NormalShaderNode
:
public
ShaderNode
{
38
public
:
39
using
ShaderNode::ShaderNode
;
40
41
void
compile
(
GPUMaterial
*material)
override
42
{
43
GPUNodeStack
*
inputs
=
get_inputs_array
();
44
GPUNodeStack
*
outputs
=
get_outputs_array
();
45
46
GPU_stack_link
(material,
47
&
bnode
(),
48
"node_composite_normal"
,
49
inputs
,
50
outputs
,
51
GPU_uniform
(
get_vector_value
()));
52
}
53
54
/* The vector value is stored in the default value of the output socket. */
55
const
float
*
get_vector_value
()
56
{
57
return
node
()
58
.output_by_identifier(
"Normal"
)
59
->default_value_typed<
bNodeSocketValueVector
>()
60
->value;
61
}
62
};
63
64
static
ShaderNode
*
get_compositor_shader_node
(
DNode
node)
65
{
66
return
new
NormalShaderNode
(node);
67
}
68
69
}
// namespace blender::nodes::node_composite_normal_cc
70
71
void
register_node_type_cmp_normal
()
72
{
73
namespace
file_ns =
blender::nodes::node_composite_normal_cc
;
74
75
static
blender::bke::bNodeType
ntype;
76
77
cmp_node_type_base
(&ntype,
CMP_NODE_NORMAL
,
"Normal"
,
NODE_CLASS_OP_VECTOR
);
78
ntype.
declare
= file_ns::cmp_node_normal_declare;
79
ntype.
get_compositor_shader_node
= file_ns::get_compositor_shader_node;
80
81
blender::bke::node_register_type
(&ntype);
82
}
NODE_CLASS_OP_VECTOR
#define NODE_CLASS_OP_VECTOR
Definition
BKE_node.hh:407
CMP_NODE_NORMAL
#define CMP_NODE_NORMAL
Definition
BKE_node.hh:1018
COM_shader_node.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:821
GPU_uniform
GPUNodeLink * GPU_uniform(const float *num)
Definition
gpu_node_graph.cc:633
PROP_DIRECTION
@ PROP_DIRECTION
Definition
RNA_types.hh:165
blender::nodes::DNode
Definition
NOD_derived_node_tree.hh:71
blender::nodes::NodeDeclarationBuilder
Definition
NOD_node_declaration.hh:525
blender::nodes::decl::Float
Definition
NOD_socket_declarations.hh:19
blender::nodes::decl::Vector
Definition
NOD_socket_declarations.hh:77
blender::nodes::decl::Vector::subtype
PropertySubType subtype
Definition
NOD_socket_declarations.hh:84
blender::nodes::node_composite_normal_cc::NormalShaderNode
Definition
node_composite_normal.cc:37
blender::nodes::node_composite_normal_cc::NormalShaderNode::ShaderNode
ShaderNode(DNode node)
Definition
shader_node.cc:22
blender::nodes::node_composite_normal_cc::NormalShaderNode::compile
void compile(GPUMaterial *material) override
Definition
node_composite_normal.cc:41
blender::nodes::node_composite_normal_cc::NormalShaderNode::get_vector_value
const float * get_vector_value()
Definition
node_composite_normal.cc:55
blender::realtime_compositor::ShaderNode
Definition
COM_shader_node.hh:31
blender::realtime_compositor::ShaderNode::get_inputs_array
GPUNodeStack * get_inputs_array()
Definition
shader_node.cc:28
blender::realtime_compositor::ShaderNode::get_outputs_array
GPUNodeStack * get_outputs_array()
Definition
shader_node.cc:33
blender::realtime_compositor::ShaderNode::ShaderNode
ShaderNode(DNode node)
Definition
shader_node.cc:22
blender::realtime_compositor::ShaderNode::node
const DNode & node() const
Definition
shader_node.cc:57
blender::realtime_compositor::ShaderNode::bnode
const bNode & bnode() const
Definition
shader_node.cc:62
b
local_group_size(16, 16) .push_constant(Type b
Definition
compositor_morphological_distance_info.hh:16
blender::bke::node_register_type
void node_register_type(bNodeType *ntype)
Definition
node.cc:1708
blender::nodes::node_composite_normal_cc
Definition
node_composite_normal.cc:17
blender::nodes::node_composite_normal_cc::cmp_node_normal_declare
static void cmp_node_normal_declare(NodeDeclarationBuilder &b)
Definition
node_composite_normal.cc:19
blender::nodes::node_composite_normal_cc::get_compositor_shader_node
static ShaderNode * get_compositor_shader_node(DNode node)
Definition
node_composite_normal.cc:64
blender::realtime_compositor
Definition
BKE_node.hh:80
register_node_type_cmp_normal
void register_node_type_cmp_normal()
Definition
node_composite_normal.cc:71
cmp_node_type_base
void cmp_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
Definition
node_composite_util.cc:31
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
min
#define min(a, b)
Definition
sort.c:32
GPUMaterial
Definition
gpu_material.cc:71
GPUNodeStack
Definition
GPU_material.hh:96
bNodeSocketValueVector
Definition
DNA_node_types.h:909
blender::bke::bNodeType
Defines a node type.
Definition
BKE_node.hh:218
blender::bke::bNodeType::declare
NodeDeclareFunction declare
Definition
BKE_node.hh:347
blender::bke::bNodeType::get_compositor_shader_node
NodeGetCompositorShaderNodeFunction get_compositor_shader_node
Definition
BKE_node.hh:328
Generated on Sat Oct 4 2025 05:32:23 for Blender by
doxygen
1.14.0