Blender V4.3
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
9#include "BLI_math_base.h"
11
12#include "UI_interface.hh"
13#include "UI_resources.hh"
14
15#include "GPU_shader.hh"
16
17#include "COM_bokeh_kernel.hh"
18#include "COM_node_operation.hh"
19
21
22/* **************** Bokeh image Tools ******************** */
23
25
27
29{
30 b.add_output<decl::Color>("Image");
31}
32
33static void node_composit_init_bokehimage(bNodeTree * /*ntree*/, bNode *node)
34{
35 NodeBokehImage *data = MEM_cnew<NodeBokehImage>(__func__);
36 data->angle = 0.0f;
37 data->flaps = 5;
38 data->rounding = 0.0f;
39 data->catadioptric = 0.0f;
40 data->lensshift = 0.0f;
41 node->storage = data;
42}
43
45{
46 uiItemR(layout, ptr, "flaps", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
47 uiItemR(layout, ptr, "angle", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
48 uiItemR(
49 layout, ptr, "rounding", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
50 uiItemR(layout,
51 ptr,
52 "catadioptric",
54 nullptr,
55 ICON_NONE);
56 uiItemR(layout, ptr, "shift", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
57}
58
59using namespace blender::realtime_compositor;
60
62 public:
64
65 void execute() override
66 {
67 const Domain domain = compute_domain();
68
69 const Result &bokeh_kernel = context().cache_manager().bokeh_kernels.get(
70 context(),
71 domain.size,
72 node_storage(bnode()).flaps,
73 node_storage(bnode()).angle,
74 node_storage(bnode()).rounding,
75 node_storage(bnode()).catadioptric,
76 node_storage(bnode()).lensshift);
77
78 Result &output = get_result("Image");
79 output.wrap_external(bokeh_kernel);
80 }
81
83 {
84 return Domain(int2(512));
85 }
86};
87
89{
90 return new BokehImageOperation(context, node);
91}
92
93} // namespace blender::nodes::node_composite_bokehimage_cc
94
96{
98
99 static blender::bke::bNodeType ntype;
100
101 cmp_node_type_base(&ntype, CMP_NODE_BOKEHIMAGE, "Bokeh Image", NODE_CLASS_INPUT);
102 ntype.declare = file_ns::cmp_node_bokehimage_declare;
103 ntype.draw_buttons = file_ns::node_composit_buts_bokehimage;
104 ntype.flag |= NODE_PREVIEW;
105 ntype.initfunc = file_ns::node_composit_init_bokehimage;
107 &ntype, "NodeBokehImage", node_free_standard_storage, node_copy_standard_storage);
108 ntype.get_compositor_operation = file_ns::get_compositor_operation;
109
111}
#define NODE_STORAGE_FUNCS(StorageT)
Definition BKE_node.hh:1799
#define NODE_CLASS_INPUT
Definition BKE_node.hh:404
@ NODE_PREVIEW
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
@ UI_ITEM_R_SLIDER
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:46
local_group_size(16, 16) .push_constant(Type b
void node_type_storage(bNodeType *ntype, const char *storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
Definition node.cc:4632
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static void cmp_node_bokehimage_declare(NodeDeclarationBuilder &b)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
static void node_composit_init_bokehimage(bNodeTree *, bNode *node)
static void node_composit_buts_bokehimage(uiLayout *layout, bContext *, PointerRNA *ptr)
VecBase< int32_t, 2 > int2
void register_node_type_cmp_bokehimage()
void cmp_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void node_free_standard_storage(bNode *node)
Definition node_util.cc:46
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:58
Defines a node type.
Definition BKE_node.hh:218
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:324
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:267
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:238
NodeDeclareFunction declare
Definition BKE_node.hh:347
PointerRNA * ptr
Definition wm_files.cc:4126