Blender V5.0
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
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>("Brightness", "Bright")
15 .default_value(0.0f)
16 .min(-100.0f)
17 .max(100.0f)
19 "Brightness correction value.\n"
20 "An additive-type factor by which to increase the overall brightness of the image. "
21 "Use a negative number to darken an image, and a positive number to brighten it");
22 b.add_input<decl::Float>("Contrast")
23 .default_value(0.0f)
24 .min(-100.0f)
25 .max(100.0f)
27 "Contrast correction value.\n"
28 "A scaling type factor by which to make brighter pixels brighter, but keeping the "
29 "darker pixels dark. "
30 "Use a negative number to decrease contrast, and a positive number to increase it");
31 b.add_output<decl::Color>("Color");
32}
33
35 bNode *node,
36 bNodeExecData * /*execdata*/,
39{
40 return GPU_stack_link(mat, node, "brightness_contrast", in, out);
41}
42
44#ifdef WITH_MATERIALX
45{
46 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
47 NodeItem bright = get_input_value("Bright", NodeItem::Type::Float);
48 NodeItem contrast = get_input_value("Contrast", NodeItem::Type::Float);
49
50 /* This formula was given from OSL shader code in Cycles. */
51 return (bright + color * (contrast + val(1.0f)) - contrast * val(0.5f)).max(val(0.0f));
52}
53#endif
55
56} // namespace blender::nodes::node_shader_brightness_cc
57
59{
61
62 static blender::bke::bNodeType ntype;
63
64 sh_node_type_base(&ntype, "ShaderNodeBrightContrast", SH_NODE_BRIGHTCONTRAST);
65 ntype.ui_name = "Brightness/Contrast";
66 ntype.ui_description = "Control the brightness and contrast of the input color";
67 ntype.enum_name_legacy = "BRIGHTCONTRAST";
69 ntype.declare = file_ns::node_declare;
70 ntype.gpu_fn = file_ns::gpu_shader_brightcontrast;
71 ntype.materialx_fn = file_ns::node_shader_materialx;
72
74}
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:449
#define SH_NODE_BRIGHTCONTRAST
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static void node_declare(NodeDeclarationBuilder &b)
static int gpu_shader_brightcontrast(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_brightcontrast()
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:238
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:344
std::string ui_description
Definition BKE_node.hh:244
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:342
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362