Blender V4.3
node_composite_split.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 "UI_interface.hh"
10#include "UI_resources.hh"
11
12#include "GPU_shader.hh"
13#include "GPU_texture.hh"
14
15#include "COM_node_operation.hh"
16#include "COM_utilities.hh"
17
19
20/* **************** SPLIT NODE ******************** */
21
23
25{
26 b.add_input<decl::Color>("Image");
27 b.add_input<decl::Color>("Image", "Image_001");
28 b.add_output<decl::Color>("Image");
29}
30
31static void node_composit_init_split(bNodeTree * /*ntree*/, bNode *node)
32{
33 node->custom1 = 50; /* default 50% split */
34}
35
37{
38 uiLayout *row, *col;
39
40 col = uiLayoutColumn(layout, false);
41 row = uiLayoutRow(col, false);
42 uiItemR(row, ptr, "axis", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
43 uiItemR(col, ptr, "factor", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
44}
45
46using namespace blender::realtime_compositor;
47
49 public:
51
52 void execute() override
53 {
54 GPUShader *shader = get_split_shader();
55 GPU_shader_bind(shader);
56
57 GPU_shader_uniform_1f(shader, "split_ratio", get_split_ratio());
58
59 const Result &first_image = get_input("Image");
60 first_image.bind_as_texture(shader, "first_image_tx");
61 const Result &second_image = get_input("Image_001");
62 second_image.bind_as_texture(shader, "second_image_tx");
63
64 const Domain domain = compute_domain();
65 Result &output_image = get_result("Image");
66 output_image.allocate_texture(domain);
67 output_image.bind_as_image(shader, "output_img");
68
69 compute_dispatch_threads_at_least(shader, domain.size);
70
71 first_image.unbind_as_texture();
72 second_image.unbind_as_texture();
73 output_image.unbind_as_image();
75 }
76
78 {
80 return context().get_shader("compositor_split_horizontal");
81 }
82
83 return context().get_shader("compositor_split_vertical");
84 }
85
90
92 {
93 return bnode().custom1 / 100.0f;
94 }
95};
96
98{
99 return new SplitOperation(context, node);
100}
101
102} // namespace blender::nodes::node_composite_split_cc
103
105{
106 namespace file_ns = blender::nodes::node_composite_split_cc;
107
108 static blender::bke::bNodeType ntype;
109
110 cmp_node_type_base(&ntype, CMP_NODE_SPLIT, "Split", NODE_CLASS_CONVERTER);
111 ntype.declare = file_ns::cmp_node_split_declare;
112 ntype.draw_buttons = file_ns::node_composit_buts_split;
113 ntype.flag |= NODE_PREVIEW;
114 ntype.initfunc = file_ns::node_composit_init_split;
115 ntype.get_compositor_operation = file_ns::get_compositor_operation;
116
117 ntype.no_muting = true;
118
120}
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:410
@ NODE_PREVIEW
CMPNodeSplitAxis
@ CMP_NODE_SPLIT_HORIZONTAL
void GPU_shader_uniform_1f(GPUShader *sh, const char *name, float value)
void GPU_shader_bind(GPUShader *shader)
void GPU_shader_unbind()
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
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_EXPAND
struct GPUShader GPUShader
GPUShader * get_shader(const char *info_name, ResultPrecision precision)
NodeOperation(Context &context, DNode node)
Result & get_input(StringRef identifier) const
Definition operation.cc:144
Result & get_result(StringRef identifier)
Definition operation.cc:46
void bind_as_image(GPUShader *shader, const char *image_name, bool read=false) const
Definition result.cc:264
void allocate_texture(Domain domain, bool from_pool=true)
Definition result.cc:204
void bind_as_texture(GPUShader *shader, const char *texture_name) const
Definition result.cc:253
local_group_size(16, 16) .push_constant(Type b
uint col
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static void node_composit_buts_split(uiLayout *layout, bContext *, PointerRNA *ptr)
static void cmp_node_split_declare(NodeDeclarationBuilder &b)
static void node_composit_init_split(bNodeTree *, bNode *node)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
void compute_dispatch_threads_at_least(GPUShader *shader, int2 threads_range, int2 local_size=int2(16))
Definition utilities.cc:131
void register_node_type_cmp_split()
void cmp_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
int16_t custom1
int16_t custom2
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