Blender V5.0
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_resources.hh"
13
14#include "COM_bokeh_kernel.hh"
15#include "COM_node_operation.hh"
16
18
19/* **************** Bokeh image Tools ******************** */
20
22
24{
25 b.add_input<decl::Int>("Flaps").default_value(5).min(3).max(24).description(
26 "The number of flaps in the bokeh");
27 b.add_input<decl::Float>("Angle")
28 .default_value(0.0f)
30 .description("The angle of the bokeh");
31 b.add_input<decl::Float>("Roundness")
32 .default_value(0.0f)
33 .min(0.0f)
34 .max(1.0f)
36 .description(
37 "Specifies how round the bokeh is, maximum roundness produces a circular bokeh");
38 b.add_input<decl::Float>("Catadioptric Size")
39 .default_value(0.0f)
41 .min(0.0f)
42 .max(1.0f)
43 .description("Specifies the size of the catadioptric iris, zero means no iris");
44 b.add_input<decl::Float>("Color Shift")
45 .default_value(0.0f)
47 .min(-1.0f)
48 .max(1.0f)
49 .description(
50 "Specifies the amount of color shifting. 1 means maximum shifting towards blue while -1 "
51 "means maximum shifting toward red");
52
53 b.add_output<decl::Color>("Image").structure_type(StructureType::Dynamic);
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.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.wrap_external(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(5), 3, 24);
87 }
88
89 float get_angle()
90 {
91 return this->get_input("Angle").get_single_value_default(0.0f);
92 }
93
95 {
96 return math::clamp(this->get_input("Roundness").get_single_value_default(0.0f), 0.0f, 1.0f);
97 }
98
100 {
101 return math::clamp(
102 this->get_input("Catadioptric Size").get_single_value_default(0.0f), 0.0f, 1.0f);
103 }
104
106 {
107 return math::clamp(this->get_input("Color Shift").get_single_value_default(0.0f), -1.0f, 1.0f);
108 }
109};
110
112{
113 return new BokehImageOperation(context, node);
114}
115
116} // namespace blender::nodes::node_composite_bokehimage_cc
117
119{
121
122 static blender::bke::bNodeType ntype;
123
124 cmp_node_type_base(&ntype, "CompositorNodeBokehImage", CMP_NODE_BOKEHIMAGE);
125 ntype.ui_name = "Bokeh Image";
126 ntype.ui_description = "Generate image with bokeh shape for use with the Bokeh Blur filter node";
127 ntype.enum_name_legacy = "BOKEHIMAGE";
128 ntype.nclass = NODE_CLASS_INPUT;
129 ntype.declare = file_ns::cmp_node_bokehimage_declare;
130 ntype.flag |= NODE_PREVIEW;
131 ntype.get_compositor_operation = file_ns::get_compositor_operation;
133
135}
constexpr int NODE_DEFAULT_MAX_WIDTH
Definition BKE_node.hh:1250
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define CMP_NODE_BOKEHIMAGE
@ NODE_PREVIEW
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ PROP_ANGLE
Definition RNA_types.hh:252
@ PROP_FACTOR
Definition RNA_types.hh:251
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(blender::gpu::Texture *texture)
Definition result.cc:584
#define output
void node_type_size(bNodeType &ntype, int width, int minwidth, int maxwidth)
Definition node.cc:5384
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
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:238
std::string ui_description
Definition BKE_node.hh:244
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:348
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362