Blender V4.5
node_composite_bokehimage.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
8
9#include "BLI_math_base.hh"
11
12#include "UI_interface.hh"
13#include "UI_resources.hh"
14
15#include "COM_bokeh_kernel.hh"
16#include "COM_node_operation.hh"
17
19
20/* **************** Bokeh image Tools ******************** */
21
23
25{
26 b.add_input<decl::Int>("Flaps")
27 .default_value(5)
28 .min(3)
29 .max(24)
30 .description("The number of flaps in the bokeh")
31 .compositor_expects_single_value();
32 b.add_input<decl::Float>("Angle")
33 .default_value(0.0f)
35 .description("The angle of the bokeh")
36 .compositor_expects_single_value();
37 b.add_input<decl::Float>("Roundness")
38 .default_value(0.0f)
39 .min(0.0f)
40 .max(1.0f)
42 .description("Specifies how round the bokeh is, maximum roundness produces a circular bokeh")
43 .compositor_expects_single_value();
44 b.add_input<decl::Float>("Catadioptric Size")
45 .default_value(0.0f)
47 .min(0.0f)
48 .max(1.0f)
49 .description("Specifies the size of the catadioptric iris, zero means no iris")
50 .compositor_expects_single_value();
51 b.add_input<decl::Float>("Color Shift")
52 .default_value(0.0f)
54 .min(-1.0f)
55 .max(1.0f)
56 .description(
57 "Specifies the amount of color shifting. 1 means maximum shifting towards blue while -1 "
58 "means maximum shifting toward red")
59 .compositor_expects_single_value();
60
61 b.add_output<decl::Color>("Image");
62}
63
64using namespace blender::compositor;
65
67 public:
69
70 void execute() override
71 {
72 const Domain domain = this->compute_domain();
73
74 const Result &bokeh_kernel = this->context().cache_manager().bokeh_kernels.get(
75 this->context(),
76 domain.size,
77 this->get_flaps(),
78 this->get_angle(),
79 this->get_roundness(),
80 this->get_catadioptric_size(),
81 this->get_color_shift());
82
83 Result &output = this->get_result("Image");
84 output.wrap_external(bokeh_kernel);
85 }
86
88 {
89 return Domain(int2(512));
90 }
91
93 {
94 return math::clamp(this->get_input("Flaps").get_single_value_default(5), 3, 24);
95 }
96
97 float get_angle()
98 {
99 return this->get_input("Angle").get_single_value_default(0.0f);
100 }
101
103 {
104 return math::clamp(this->get_input("Roundness").get_single_value_default(0.0f), 0.0f, 1.0f);
105 }
106
108 {
109 return math::clamp(
110 this->get_input("Catadioptric Size").get_single_value_default(0.0f), 0.0f, 1.0f);
111 }
112
114 {
115 return math::clamp(this->get_input("Color Shift").get_single_value_default(0.0f), -1.0f, 1.0f);
116 }
117};
118
120{
121 return new BokehImageOperation(context, node);
122}
123
124} // namespace blender::nodes::node_composite_bokehimage_cc
125
127{
129
130 static blender::bke::bNodeType ntype;
131
132 cmp_node_type_base(&ntype, "CompositorNodeBokehImage", CMP_NODE_BOKEHIMAGE);
133 ntype.ui_name = "Bokeh Image";
134 ntype.ui_description = "Generate image with bokeh shape for use with the Bokeh Blur filter node";
135 ntype.enum_name_legacy = "BOKEHIMAGE";
136 ntype.nclass = NODE_CLASS_INPUT;
137 ntype.declare = file_ns::cmp_node_bokehimage_declare;
138 ntype.flag |= NODE_PREVIEW;
139 ntype.get_compositor_operation = file_ns::get_compositor_operation;
140
142}
#define NODE_CLASS_INPUT
Definition BKE_node.hh:433
#define CMP_NODE_BOKEHIMAGE
@ NODE_PREVIEW
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ PROP_ANGLE
Definition RNA_types.hh:240
@ PROP_FACTOR
Definition RNA_types.hh:239
Result & get(Context &context, int2 size, int sides, float rotation, float roundness, float catadioptric, float lens_shift)
NodeOperation(Context &context, DNode node)
Result & get_result(StringRef identifier)
Definition operation.cc:39
Result & get_input(StringRef identifier) const
Definition operation.cc:138
T get_single_value_default(const T &default_value) const
void wrap_external(GPUTexture *texture)
Definition result.cc:448
#define this
#define output
void node_register_type(bNodeType &ntype)
Definition node.cc:2748
T clamp(const T &a, const T &min, const T &max)
static void cmp_node_bokehimage_declare(NodeDeclarationBuilder &b)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
VecBase< int32_t, 2 > int2
static void register_node_type_cmp_bokehimage()
void cmp_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
std::string ui_description
Definition BKE_node.hh:232
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:336
const char * enum_name_legacy
Definition BKE_node.hh:235
NodeDeclareFunction declare
Definition BKE_node.hh:355