Blender V5.3
node_composite_bokeh_image.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 "BLI_math_base.hh"
7
8#include "COM_bokeh_kernel.hh"
10
12
14
16{
17 b.add_input<decl::Int>("Flaps"_ustr)
18 .default_value(5)
19 .min(3)
20 .max(24)
21 .description("The number of flaps in the bokeh");
22 b.add_input<decl::Float>("Angle"_ustr)
23 .default_value(0.0f)
25 .description("The angle of the bokeh");
26 b.add_input<decl::Float>("Roundness"_ustr)
27 .default_value(0.0f)
28 .min(0.0f)
29 .max(1.0f)
31 .description(
32 "Specifies how round the bokeh is, maximum roundness produces a circular bokeh");
33 b.add_input<decl::Float>("Catadioptric Size"_ustr)
34 .default_value(0.0f)
36 .min(0.0f)
37 .max(1.0f)
38 .description("Specifies the size of the catadioptric iris, zero means no iris");
39 b.add_input<decl::Float>("Color Shift"_ustr)
40 .default_value(0.0f)
42 .min(-1.0f)
43 .max(1.0f)
44 .description(
45 "Specifies the amount of color shifting. 1 means maximum shifting towards blue while -1 "
46 "means maximum shifting toward red");
47
48 b.add_output<decl::Color>("Image"_ustr).structure_type(StructureType::Dynamic);
49}
50
51static void node_init(bNodeTree * /*node_tree*/, bNode *node)
52{
53 node->flag |= NODE_PREVIEW;
54}
55
56using namespace blender::compositor;
57
59 public:
61
62 void execute() override
63 {
64 const Domain domain = this->compute_domain();
65
66 const Result &bokeh_kernel = this->context().cache_manager().bokeh_kernels.get(
67 this->context(),
68 domain.data_size,
69 this->get_flaps(),
70 this->get_angle(),
71 this->get_roundness(),
72 this->get_catadioptric_size(),
73 this->get_color_shift());
74
75 Result &output = this->get_result("Image");
76 output.share_data(bokeh_kernel);
77 }
78
80 {
81 return Domain(int2(512));
82 }
83
85 {
86 return math::clamp(this->get_input("Flaps").get_single_value_default<int>(), 3, 24);
87 }
88
89 float get_angle()
90 {
91 return this->get_input("Angle").get_single_value_default<float>();
92 }
93
95 {
96 return math::clamp(this->get_input("Roundness").get_single_value_default<float>(), 0.0f, 1.0f);
97 }
98
100 {
101 return math::clamp(
102 this->get_input("Catadioptric Size").get_single_value_default<float>(), 0.0f, 1.0f);
103 }
104
106 {
107 return math::clamp(
108 this->get_input("Color Shift").get_single_value_default<float>(), -1.0f, 1.0f);
109 }
110};
111
113{
114 return new BokehImageOperation(context, node);
115}
116
117static void node_register()
118{
119 static bke::bNodeType ntype;
120
121 cmp_node_type_base(&ntype, "CompositorNodeBokehImage"_ustr, CMP_NODE_BOKEHIMAGE);
122 ntype.ui_name = "Bokeh Image";
123 ntype.ui_description = "Generate image with bokeh shape for use with the Bokeh Blur filter node";
124 ntype.enum_name_legacy = "BOKEHIMAGE";
125 ntype.nclass = NODE_CLASS_INPUT;
126 ntype.declare = node_declare;
127 ntype.initfunc = node_init;
128 ntype.flag |= NODE_PREVIEW;
131
133}
135
136} // namespace blender::nodes::node_composite_bokeh_image_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define CMP_NODE_BOKEHIMAGE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define output
Result & get(Context &context, int2 size, int sides, float rotation, float roundness, float catadioptric, float lens_shift)
Domain(const int2 &size)
Definition domain.cc:20
NodeOperation(Context &context, const bNode &node)
Result & get_result(StringRef identifier)
Definition operation.cc:40
Context & context() const
Definition operation.cc:57
Result & get_input(StringRef identifier) const
Definition operation.cc:35
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
T clamp(const T &a, const T &min, const T &max)
static NodeOperation * get_compositor_operation(Context &context, const bNode &node)
static void node_declare(NodeDeclarationBuilder &b)
@ PROP_FACTOR
Definition RNA_types.hh:308
void cmp_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
static constexpr int _160
Definition BKE_node.hh:246
Defines a node type.
Definition BKE_node.hh:265
std::string ui_description
Definition BKE_node.hh:271
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:379
void(*) initfunc(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:320
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393