Blender
V5.0
source
blender
nodes
composite
nodes
node_composite_val_to_rgb.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 "
IMB_colormanagement.hh
"
17
18
#include "
GPU_material.hh
"
19
20
#include "
node_composite_util.hh
"
21
22
namespace
blender::nodes::node_composite_rgb_to_bw_cc
{
23
24
static
void
cmp_node_rgbtobw_declare
(
NodeDeclarationBuilder
&
b
)
25
{
26
b
.is_function_node();
27
b
.add_input<
decl::Color
>(
"Image"
).default_value({0.8f, 0.8f, 0.8f, 1.0f});
28
b
.add_output<
decl::Float
>(
"Val"
);
29
}
30
31
using namespace
blender::compositor
;
32
33
static
int
node_gpu_material
(
GPUMaterial
*material,
34
bNode
*node,
35
bNodeExecData
*
/*execdata*/
,
36
GPUNodeStack
*
inputs
,
37
GPUNodeStack
*
outputs
)
38
{
39
float
luminance_coefficients[3];
40
IMB_colormanagement_get_luminance_coefficients
(luminance_coefficients);
41
42
return
GPU_stack_link
(
43
material, node,
"color_to_luminance"
,
inputs
,
outputs
,
GPU_constant
(luminance_coefficients));
44
}
45
46
static
void
node_build_multi_function
(
blender::nodes::NodeMultiFunctionBuilder
&builder)
47
{
48
float3
luminance_coefficients;
49
IMB_colormanagement_get_luminance_coefficients
(luminance_coefficients);
50
51
builder.
construct_and_set_matching_fn_cb
([=]() {
52
return
mf::build::SI1_SO<float4, float>(
53
"RGB to BW"
,
54
[=](
const
float4
&
color
) ->
float
{
55
return
math::dot
(
color
.xyz(), luminance_coefficients);
56
},
57
mf::build::exec_presets::AllSpanOrSingle());
58
});
59
}
60
61
}
// namespace blender::nodes::node_composite_rgb_to_bw_cc
62
63
static
void
register_node_type_cmp_rgbtobw
()
64
{
65
namespace
file_ns =
blender::nodes::node_composite_rgb_to_bw_cc
;
66
67
static
blender::bke::bNodeType
ntype;
68
69
cmp_node_type_base
(&ntype,
"CompositorNodeRGBToBW"
,
CMP_NODE_RGBTOBW
);
70
ntype.
ui_name
=
"RGB to BW"
;
71
ntype.
ui_description
=
"Convert RGB input into grayscale using luminance"
;
72
ntype.
enum_name_legacy
=
"RGBTOBW"
;
73
ntype.
nclass
=
NODE_CLASS_CONVERTER
;
74
ntype.
declare
= file_ns::cmp_node_rgbtobw_declare;
75
blender::bke::node_type_size_preset
(ntype,
blender::bke::eNodeSizePreset::Default
);
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_rgbtobw
)
NODE_CLASS_CONVERTER
#define NODE_CLASS_CONVERTER
Definition
BKE_node.hh:453
CMP_NODE_RGBTOBW
#define CMP_NODE_RGBTOBW
Definition
BKE_node_legacy_types.hh:154
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
GPU_constant
GPUNodeLink * GPU_constant(const float *num)
Definition
gpu_node_graph.cc:653
IMB_colormanagement.hh
IMB_colormanagement_get_luminance_coefficients
BLI_INLINE void IMB_colormanagement_get_luminance_coefficients(float r_rgb[3])
Definition
colormanagement_inline.h:18
NOD_multi_function.hh
NOD_REGISTER_NODE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
Definition
NOD_register.hh:34
blender::nodes::NodeDeclarationBuilder
Definition
NOD_node_declaration.hh:664
blender::nodes::NodeMultiFunctionBuilder
Definition
NOD_multi_function.hh:18
blender::nodes::NodeMultiFunctionBuilder::construct_and_set_matching_fn_cb
void construct_and_set_matching_fn_cb(Fn &&create_multi_function)
Definition
NOD_multi_function.hh:117
blender::nodes::decl::Color
Definition
NOD_socket_declarations.hh:139
blender::nodes::decl::Float
Definition
NOD_socket_declarations.hh:25
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::bke::eNodeSizePreset::Default
@ Default
Definition
BKE_node.hh:1161
blender::bke::node_type_size_preset
void node_type_size_preset(bNodeType &ntype, eNodeSizePreset size)
Definition
node.cc:5396
blender::color
Definition
BLI_color.hh:32
blender::compositor
Definition
BKE_node.hh:77
blender::math::dot
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
Definition
BLI_math_quaternion.hh:197
blender::nodes::node_composite_rgb_to_bw_cc
Definition
node_composite_val_to_rgb.cc:22
blender::nodes::node_composite_rgb_to_bw_cc::cmp_node_rgbtobw_declare
static void cmp_node_rgbtobw_declare(NodeDeclarationBuilder &b)
Definition
node_composite_val_to_rgb.cc:24
blender::nodes::node_composite_rgb_to_bw_cc::node_build_multi_function
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
Definition
node_composite_val_to_rgb.cc:46
blender::nodes::node_composite_rgb_to_bw_cc::node_gpu_material
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
Definition
node_composite_val_to_rgb.cc:33
blender::float4
VecBase< float, 4 > float4
Definition
BLI_math_vector_types.hh:620
blender::float3
VecBase< float, 3 > float3
Definition
BLI_math_vector_types.hh:619
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
register_node_type_cmp_rgbtobw
static void register_node_type_cmp_rgbtobw()
Definition
node_composite_val_to_rgb.cc:63
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