Blender V4.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
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*/,
33 GPUNodeStack *in,
34 GPUNodeStack *out)
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, SH_NODE_BRIGHTCONTRAST, "Brightness/Contrast", NODE_CLASS_OP_COLOR);
61 ntype.declare = file_ns::node_declare;
62 ntype.gpu_fn = file_ns::gpu_shader_brightcontrast;
63 ntype.materialx_fn = file_ns::node_shader_materialx;
64
66}
#define SH_NODE_BRIGHTCONTRAST
Definition BKE_node.hh:948
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:406
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
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, int type, const char *name, short nclass)
Defines a node type.
Definition BKE_node.hh:218
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:320
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:318
NodeDeclareFunction declare
Definition BKE_node.hh:347