31 b.add_input<
decl::Color>(
"Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
45 return GPU_stack_link(material, node,
"node_composite_bright_contrast", inputs, outputs);
51 const float brightness,
54 float scaled_brightness = brightness / 100.0f;
55 float delta = contrast / 200.0f;
57 float multiplier, offset;
58 if (contrast > 0.0f) {
59 multiplier = 1.0f - delta * 2.0f;
60 multiplier = 1.0f /
math::max(multiplier, std::numeric_limits<float>::epsilon());
61 offset = multiplier * (scaled_brightness - delta);
65 multiplier =
math::max(1.0f - delta * 2.0f, 0.0f);
66 offset = multiplier * scaled_brightness + delta;
74 static auto function = mf::build::SI3_SO<float4, float, float, float4>(
75 "Bright And Contrast",
79 mf::build::exec_presets::SomeSpanOrSingle<0>());
92 ntype.
ui_name =
"Brightness/Contrast";
96 ntype.
declare = file_ns::cmp_node_brightcontrast_declare;
97 ntype.
gpu_fn = file_ns::node_gpu_material;
#define NODE_CLASS_OP_COLOR
#define CMP_NODE_BRIGHTCONTRAST
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void set_matching_fn(const mf::MultiFunction *fn)
void node_register_type(bNodeType &ntype)
T max(const T &a, const T &b)
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
static void cmp_node_brightcontrast_declare(NodeDeclarationBuilder &b)
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
static float4 brightness_and_contrast(const float4 &color, const float brightness, const float contrast)
VecBase< float, 4 > float4
static void register_node_type_cmp_brightcontrast()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
std::string ui_description
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
const char * enum_name_legacy
NodeDeclareFunction declare