Blender
V4.5
source
blender
nodes
composite
nodes
node_composite_gamma.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 "
NOD_multi_function.hh
"
13
14
#include "
FN_multi_function_builder.hh
"
15
16
#include "
GPU_material.hh
"
17
18
#include "
node_composite_util.hh
"
19
20
/* **************** Gamma Tools ******************** */
21
22
namespace
blender::nodes::node_composite_gamma_cc
{
23
24
static
void
cmp_node_gamma_declare
(
NodeDeclarationBuilder
&
b
)
25
{
26
b
.add_input<
decl::Color
>(
"Image"
)
27
.default_value({1.0f, 1.0f, 1.0f, 1.0f})
28
.compositor_domain_priority(0);
29
b
.add_input<
decl::Float
>(
"Gamma"
)
30
.default_value(1.0f)
31
.min(0.001f)
32
.max(10.0f)
33
.
subtype
(
PROP_UNSIGNED
)
34
.compositor_domain_priority(1)
35
.description(
36
"Gamma correction value, applied as color^gamma.\n"
37
"Typically used to convert from gamma encoded to linear color space, or in the reverse "
38
"direction with 1/gamma"
);
39
b
.add_output<
decl::Color
>(
"Image"
);
40
}
41
42
using namespace
blender::compositor
;
43
44
static
int
node_gpu_material
(
GPUMaterial
*material,
45
bNode
*node,
46
bNodeExecData
*
/*execdata*/
,
47
GPUNodeStack
*
inputs
,
48
GPUNodeStack
*
outputs
)
49
{
50
return
GPU_stack_link
(material, node,
"node_composite_gamma"
,
inputs
,
outputs
);
51
}
52
53
static
void
node_build_multi_function
(
blender::nodes::NodeMultiFunctionBuilder
&builder)
54
{
55
static
auto
gamma_function = mf::build::SI2_SO<float4, float, float4>(
56
"Gamma"
,
57
[](
const
float4
&
color
,
const
float
gamma) ->
float4
{
58
return
float4
(
math::safe_pow
(
color
.xyz(), gamma),
color
.w);
59
},
60
mf::build::exec_presets::SomeSpanOrSingle<0>());
61
builder.
set_matching_fn
(gamma_function);
62
}
63
64
}
// namespace blender::nodes::node_composite_gamma_cc
65
66
static
void
register_node_type_cmp_gamma
()
67
{
68
namespace
file_ns =
blender::nodes::node_composite_gamma_cc
;
69
70
static
blender::bke::bNodeType
ntype;
71
72
cmp_node_type_base
(&ntype,
"CompositorNodeGamma"
,
CMP_NODE_GAMMA
);
73
ntype.
ui_name
=
"Gamma"
;
74
ntype.
ui_description
=
"Apply gamma correction"
;
75
ntype.
enum_name_legacy
=
"GAMMA"
;
76
ntype.
nclass
=
NODE_CLASS_OP_COLOR
;
77
ntype.
declare
= file_ns::cmp_node_gamma_declare;
78
ntype.
gpu_fn
= file_ns::node_gpu_material;
79
ntype.
build_multi_function
= file_ns::node_build_multi_function;
80
81
blender::bke::node_register_type
(ntype);
82
}
83
NOD_REGISTER_NODE
(
register_node_type_cmp_gamma
)
NODE_CLASS_OP_COLOR
#define NODE_CLASS_OP_COLOR
Definition
BKE_node.hh:435
CMP_NODE_GAMMA
#define CMP_NODE_GAMMA
Definition
BKE_node_legacy_types.hh:199
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:825
NOD_multi_function.hh
NOD_REGISTER_NODE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
Definition
NOD_register.hh:34
PROP_UNSIGNED
@ PROP_UNSIGNED
Definition
RNA_types.hh:237
blender::nodes::NodeDeclarationBuilder
Definition
NOD_node_declaration.hh:629
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::Color
Definition
NOD_socket_declarations.hh:133
blender::nodes::decl::Float
Definition
NOD_socket_declarations.hh:19
blender::nodes::decl::Float::subtype
PropertySubType subtype
Definition
NOD_socket_declarations.hh:26
b
b
Definition
compositor_morphological_distance_info.hh:24
blender::bke::node_register_type
void node_register_type(bNodeType &ntype)
Definition
node.cc:2748
blender::color
Definition
BLI_color_mix.hh:21
blender::compositor
Definition
BKE_node.hh:76
blender::math::safe_pow
T safe_pow(const T &x, const T &power)
Definition
BLI_math_base.hh:187
blender::nodes::node_composite_gamma_cc
Definition
node_composite_gamma.cc:22
blender::nodes::node_composite_gamma_cc::node_build_multi_function
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
Definition
node_composite_gamma.cc:53
blender::nodes::node_composite_gamma_cc::cmp_node_gamma_declare
static void cmp_node_gamma_declare(NodeDeclarationBuilder &b)
Definition
node_composite_gamma.cc:24
blender::nodes::node_composite_gamma_cc::node_gpu_material
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
Definition
node_composite_gamma.cc:44
blender::float4
VecBase< float, 4 > float4
Definition
BLI_math_vector_types.hh:620
register_node_type_cmp_gamma
static void register_node_type_cmp_gamma()
Definition
node_composite_gamma.cc:66
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:60
GPUNodeStack
Definition
GPU_material.hh:272
bNodeExecData
Definition
node_util.hh:19
bNode
Definition
DNA_node_types.h:415
blender::bke::bNodeType
Defines a node type.
Definition
BKE_node.hh:226
blender::bke::bNodeType::ui_description
std::string ui_description
Definition
BKE_node.hh:232
blender::bke::bNodeType::ui_name
std::string ui_name
Definition
BKE_node.hh:231
blender::bke::bNodeType::gpu_fn
NodeGPUExecFunction gpu_fn
Definition
BKE_node.hh:330
blender::bke::bNodeType::build_multi_function
NodeMultiFunctionBuildFunction build_multi_function
Definition
BKE_node.hh:344
blender::bke::bNodeType::nclass
short nclass
Definition
BKE_node.hh:239
blender::bke::bNodeType::enum_name_legacy
const char * enum_name_legacy
Definition
BKE_node.hh:235
blender::bke::bNodeType::declare
NodeDeclareFunction declare
Definition
BKE_node.hh:355
Generated on
for Blender by
doxygen
1.16.1