Blender V4.5
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>("Bright").default_value(0.0f).min(-100.0f).max(100.0f).description(
15 "Brightness correction value.\n"
16 "An additive-type factor by which to increase the overall brightness of the image. "
17 "Use a negative number to darken an image, and a positive number to brighten it");
18 b.add_input<decl::Float>("Contrast")
19 .default_value(0.0f)
20 .min(-100.0f)
21 .max(100.0f)
23 "Contrast correction value.\n"
24 "A scaling type factor by which to make brighter pixels brighter, but keeping the "
25 "darker pixels dark. "
26 "Use a negative number to decrease contrast, and a positive number to increase it");
27 b.add_output<decl::Color>("Color");
28}
29
31 bNode *node,
32 bNodeExecData * /*execdata*/,
35{
36 return GPU_stack_link(mat, node, "brightness_contrast", in, out);
37}
38
40#ifdef WITH_MATERIALX
41{
42 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
43 NodeItem bright = get_input_value("Bright", NodeItem::Type::Float);
44 NodeItem contrast = get_input_value("Contrast", NodeItem::Type::Float);
45
46 /* This formula was given from OSL shader code in Cycles. */
47 return (bright + color * (contrast + val(1.0f)) - contrast * val(0.5f)).max(val(0.0f));
48}
49#endif
51
52} // namespace blender::nodes::node_shader_brightness_cc
53
55{
57
58 static blender::bke::bNodeType ntype;
59
60 sh_node_type_base(&ntype, "ShaderNodeBrightContrast", SH_NODE_BRIGHTCONTRAST);
61 ntype.ui_name = "Brightness/Contrast";
62 ntype.ui_description = "Control the brightness and contrast of the input color";
63 ntype.enum_name_legacy = "BRIGHTCONTRAST";
65 ntype.declare = file_ns::node_declare;
66 ntype.gpu_fn = file_ns::gpu_shader_brightcontrast;
67 ntype.materialx_fn = file_ns::node_shader_materialx;
68
70}
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:435
#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:2748
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: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