Blender V4.5
node_shader_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
5#include "node_shader_util.hh"
6
8
10{
11 b.add_input<decl::Color>("Color")
12 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
13 .description("Color input on which correction will be applied");
14 b.add_input<decl::Float>("Gamma")
15 .default_value(1.0f)
16 .min(0.001f)
17 .max(10.0f)
19 .description(
20 "Gamma correction value, applied as color^gamma.\n"
21 "Gamma controls the relative intensity of the mid-tones compared to the full black and "
22 "full white");
23 b.add_output<decl::Color>("Color");
24}
25
27 bNode *node,
28 bNodeExecData * /*execdata*/,
31{
32 return GPU_stack_link(mat, node, "node_gamma", in, out);
33}
34
36#ifdef WITH_MATERIALX
37{
38 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
39 NodeItem gamma = get_input_value("Gamma", NodeItem::Type::Float);
40 return color ^ gamma;
41}
42#endif
44
45} // namespace blender::nodes::node_shader_gamma_cc
46
48{
49 namespace file_ns = blender::nodes::node_shader_gamma_cc;
50
51 static blender::bke::bNodeType ntype;
52
53 sh_node_type_base(&ntype, "ShaderNodeGamma", SH_NODE_GAMMA);
54 ntype.ui_name = "Gamma";
55 ntype.ui_description = "Apply a gamma correction";
56 ntype.enum_name_legacy = "GAMMA";
58 ntype.declare = file_ns::node_declare;
59 ntype.gpu_fn = file_ns::node_shader_gpu_gamma;
60 ntype.materialx_fn = file_ns::node_shader_materialx;
61
63}
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:435
#define SH_NODE_GAMMA
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ PROP_NONE
Definition RNA_types.hh:221
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2748
static int node_shader_gpu_gamma(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_declare(NodeDeclarationBuilder &b)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_gamma()
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:226
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:332
std::string ui_description
Definition BKE_node.hh:232
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:330
const char * enum_name_legacy
Definition BKE_node.hh:235
NodeDeclareFunction declare
Definition BKE_node.hh:355