Blender V4.3
COM_BlurNode.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "COM_BlurNode.h"
13
14namespace blender::compositor {
15
16BlurNode::BlurNode(bNode *editor_node) : Node(editor_node)
17{
18 /* pass */
19}
20
22 const CompositorContext & /*context*/) const
23{
24 const bNode *editor_node = this->get_bnode();
25 const NodeBlurData *data = (const NodeBlurData *)editor_node->storage;
26 NodeInput *input_size_socket = this->get_input_socket(1);
27 bool connected_size_socket = input_size_socket->is_linked();
28
29 const float size = this->get_input_socket(1)->get_editor_value_float();
30 const bool extend_bounds = (editor_node->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0;
31
32 NodeOperation *input_operation = nullptr, *output_operation = nullptr;
33
34 if (data->filtertype == R_FILTER_FAST_GAUSS) {
36 operationfgb->set_data(data);
37 operationfgb->set_extend_bounds(extend_bounds);
38 converter.add_operation(operationfgb);
39
40 converter.map_input_socket(get_input_socket(1), operationfgb->get_input_socket(1));
41
42 input_operation = operationfgb;
43 output_operation = operationfgb;
44 }
45 else if ((editor_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) && connected_size_socket) {
48 zero->set_value(0.0f);
49 clamp->set_use_clamp(true);
50
51 converter.add_operation(clamp);
52 converter.add_operation(zero);
53 converter.map_input_socket(get_input_socket(1), clamp->get_input_socket(0));
54 converter.add_link(zero->get_output_socket(), clamp->get_input_socket(1));
55
57 operation->set_data(data);
58 operation->set_extend_bounds(extend_bounds);
59
60 converter.add_operation(operation);
61 converter.add_link(clamp->get_output_socket(), operation->get_input_socket(1));
62
63 output_operation = operation;
64 input_operation = operation;
65 }
66 else if (!data->bokeh) {
68 operationx->set_data(data);
69 operationx->set_extend_bounds(extend_bounds);
70
71 converter.add_operation(operationx);
72 converter.map_input_socket(get_input_socket(1), operationx->get_input_socket(1));
73
75 operationy->set_data(data);
76 operationy->set_extend_bounds(extend_bounds);
77
78 converter.add_operation(operationy);
79 converter.map_input_socket(get_input_socket(1), operationy->get_input_socket(1));
80 converter.add_link(operationx->get_output_socket(), operationy->get_input_socket(0));
81
82 if (!connected_size_socket) {
83 operationx->set_size(size);
84 operationy->set_size(size);
85 }
86
87 input_operation = operationx;
88 output_operation = operationy;
89 }
90 else {
92 operation->set_data(data);
93 operation->set_extend_bounds(extend_bounds);
94
95 converter.add_operation(operation);
96 converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
97
98 if (!connected_size_socket) {
99 operation->set_size(size);
100 }
101
102 input_operation = operation;
103 output_operation = operation;
104 }
105
106 if (data->gamma) {
109 converter.add_operation(correct);
110 converter.add_operation(inverse);
111
112 converter.map_input_socket(get_input_socket(0), correct->get_input_socket(0));
113 converter.add_link(correct->get_output_socket(), input_operation->get_input_socket(0));
114 converter.add_link(output_operation->get_output_socket(), inverse->get_input_socket(0));
115 converter.map_output_socket(get_output_socket(), inverse->get_output_socket());
116
117 converter.add_preview(inverse->get_output_socket());
118 }
119 else {
120 converter.map_input_socket(get_input_socket(0), input_operation->get_input_socket(0));
121 converter.map_output_socket(get_output_socket(), output_operation->get_output_socket());
122
123 converter.add_preview(output_operation->get_output_socket());
124 }
125}
126
127} // namespace blender::compositor
@ CMP_NODEFLAG_BLUR_VARIABLE_SIZE
@ CMP_NODEFLAG_BLUR_EXTEND_BOUNDS
@ R_FILTER_FAST_GAUSS
btMatrix3x3 inverse() const
Return the inverse of the matrix.
BlurNode(bNode *editor_node)
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
Overall context of the compositor.
void add_link(NodeOperationOutput *from, NodeOperationInput *to)
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
void add_preview(NodeOperationOutput *output)
void add_operation(NodeOperation *operation)
void map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket)
NodeInput are sockets that can receive data/input.
Definition COM_Node.h:191
float get_editor_value_float() const
Definition COM_Node.cc:136
NodeOperation contains calculation logic.
NodeOperationOutput * get_output_socket(unsigned int index=0)
NodeOperationInput * get_input_socket(unsigned int index)
NodeOutput * get_output_socket(unsigned int index=0) const
Definition COM_Node.cc:85
NodeInput * get_input_socket(unsigned int index) const
Definition COM_Node.cc:90
const bNode * get_bnode() const
get the reference to the SDNA bNode struct
Definition COM_Node.h:65
int16_t custom1
void * storage