Blender V5.0
node_composite_exposure.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cmath>
10
12
14
15#include "NOD_multi_function.hh"
16
17#include "GPU_material.hh"
18
20
21/* **************** Exposure ******************** */
22
24
26{
27 b.use_custom_socket_order();
28 b.allow_any_socket_order();
29 b.is_function_node();
30 b.add_input<decl::Color>("Image").default_value({1.0f, 1.0f, 1.0f, 1.0f}).hide_value();
31 b.add_output<decl::Color>("Image").align_with_previous();
32
33 b.add_input<decl::Float>("Exposure").min(-10.0f).max(10.0f);
34}
35
36using namespace blender::compositor;
37
38static int node_gpu_material(GPUMaterial *material,
39 bNode *node,
40 bNodeExecData * /*execdata*/,
43{
44 return GPU_stack_link(material, node, "node_composite_exposure", inputs, outputs);
45}
46
48{
49 static auto function = mf::build::SI2_SO<float4, float, float4>(
50 "Exposure",
51 [](const float4 &color, const float exposure) -> float4 {
52 return float4(color.xyz() * std::exp2(exposure), color.w);
53 },
54 mf::build::exec_presets::SomeSpanOrSingle<0>());
55 builder.set_matching_fn(function);
56}
57
58} // namespace blender::nodes::node_composite_exposure_cc
59
61{
63
64 static blender::bke::bNodeType ntype;
65
66 cmp_node_type_base(&ntype, "CompositorNodeExposure", CMP_NODE_EXPOSURE);
67 ntype.ui_name = "Exposure";
68 ntype.ui_description = "Adjust brightness using a camera exposure parameter";
69 ntype.enum_name_legacy = "EXPOSURE";
71 ntype.declare = file_ns::cmp_node_exposure_declare;
72 ntype.gpu_fn = file_ns::node_gpu_material;
73 ntype.build_multi_function = file_ns::node_build_multi_function;
74
76}
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:449
#define CMP_NODE_EXPOSURE
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)
Definition node.cc:2416
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
static void cmp_node_exposure_declare(NodeDeclarationBuilder &b)
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
VecBase< float, 4 > float4
static void register_node_type_cmp_exposure()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
static blender::bke::bNodeSocketTemplate outputs[]
static blender::bke::bNodeSocketTemplate inputs[]
#define min(a, b)
Definition sort.cc:36
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:342
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:351
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362