Blender V5.3
node_shader_brightness.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 "node_shader_util.hh"
10
11namespace blender {
12
14
16{
17 b.add_input<decl::Color>("Color"_ustr)
18 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
19 .description("Color input on which correction will be applied");
20 b.add_input<decl::Float>("Brightness"_ustr, "Bright"_ustr)
21 .default_value(0.0f)
22 .min(-100.0f)
23 .max(100.0f)
25 "Brightness correction value.\n"
26 "An additive-type factor by which to increase the overall brightness of the image. "
27 "Use a negative number to darken an image, and a positive number to brighten it");
28 b.add_input<decl::Float>("Contrast"_ustr)
29 .default_value(0.0f)
30 .min(-100.0f)
31 .max(100.0f)
33 "Contrast correction value.\n"
34 "A scaling type factor by which to make brighter pixels brighter, but keeping the "
35 "darker pixels dark. "
36 "Use a negative number to decrease contrast, and a positive number to increase it");
37 b.add_output<decl::Color>("Color"_ustr);
38}
39
41 bNode *node,
42 bNodeExecData * /*execdata*/,
45{
46 return GPU_stack_link(mat, node, "brightness_contrast", in, out);
47}
48
50#ifdef WITH_MATERIALX
51{
52 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
53 NodeItem bright = get_input_value("Bright", NodeItem::Type::Float);
54 NodeItem contrast = get_input_value("Contrast", NodeItem::Type::Float);
55
56 /* This formula was given from OSL shader code in Cycles. */
57 return (bright + color * (contrast + val(1.0f)) - contrast * val(0.5f)).max(val(0.0f));
58}
59#endif
61
62} // namespace nodes::node_shader_brightness_cc
63
65{
66 namespace file_ns = nodes::node_shader_brightness_cc;
67
68 static bke::bNodeType ntype;
69
70 sh_node_type_base(&ntype, "ShaderNodeBrightContrast"_ustr, SH_NODE_BRIGHTCONTRAST);
71 ntype.ui_name = "Brightness/Contrast";
72 ntype.ui_description = "Control the brightness and contrast of the input color";
73 ntype.enum_name_legacy = "BRIGHTCONTRAST";
75 ntype.declare = file_ns::node_declare;
76 ntype.gpu_fn = file_ns::gpu_shader_brightcontrast;
77 ntype.materialx_fn = file_ns::node_shader_materialx;
78
80}
81
82} // namespace blender
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:480
#define SH_NODE_BRIGHTCONTRAST
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_declare(NodeDeclarationBuilder &b)
static int gpu_shader_brightcontrast(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
BMesh Iterators.
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void register_node_type_sh_brightcontrast()
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
Defines a node type.
Definition BKE_node.hh:265
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:375
std::string ui_description
Definition BKE_node.hh:271
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:373
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393