Blender V4.3
COM_FilterNode.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_FilterNode.h"
6#include "BKE_node.hh"
8
9namespace blender::compositor {
10
11FilterNode::FilterNode(bNode *editor_node) : Node(editor_node)
12{
13 /* pass */
14}
15
17 const CompositorContext & /*context*/) const
18{
19 NodeInput *input_socket = this->get_input_socket(0);
20 NodeInput *input_image_socket = this->get_input_socket(1);
21 NodeOutput *output_socket = this->get_output_socket(0);
22 ConvolutionFilterOperation *operation = nullptr;
23
24 switch (this->get_bnode()->custom1) {
26 operation = new ConvolutionFilterOperation();
27 operation->set3x3Filter(1 / 16.0f,
28 2 / 16.0f,
29 1 / 16.0f,
30 2 / 16.0f,
31 4 / 16.0f,
32 2 / 16.0f,
33 1 / 16.0f,
34 2 / 16.0f,
35 1 / 16.0f);
36 break;
38 operation = new ConvolutionFilterOperation();
39 operation->set3x3Filter(-1, -1, -1, -1, 9, -1, -1, -1, -1);
40 break;
42 operation = new ConvolutionEdgeFilterOperation();
43 operation->set3x3Filter(-1 / 8.0f,
44 -1 / 8.0f,
45 -1 / 8.0f,
46 -1 / 8.0f,
47 1.0f,
48 -1 / 8.0f,
49 -1 / 8.0f,
50 -1 / 8.0f,
51 -1 / 8.0f);
52 break;
54 operation = new ConvolutionEdgeFilterOperation();
55 operation->set3x3Filter(1, 2, 1, 0, 0, 0, -1, -2, -1);
56 break;
58 operation = new ConvolutionEdgeFilterOperation();
59 operation->set3x3Filter(1, 1, 1, 0, 0, 0, -1, -1, -1);
60 break;
62 operation = new ConvolutionEdgeFilterOperation();
63 operation->set3x3Filter(5, 5, 5, -3, -3, -3, -2, -2, -2);
64 break;
66 operation = new ConvolutionFilterOperation();
67 operation->set3x3Filter(1, 2, 1, 0, 1, 0, -1, -2, -1);
68 break;
70 operation = new ConvolutionFilterOperation();
71 operation->set3x3Filter(0, -1, 0, -1, 5, -1, 0, -1, 0);
72 break;
73 default:
74 operation = new ConvolutionFilterOperation();
75 operation->set3x3Filter(0, 0, 0, 0, 1, 0, 0, 0, 0);
76 break;
77 }
78 converter.add_operation(operation);
79
80 converter.map_input_socket(input_image_socket, operation->get_input_socket(0));
81 converter.map_input_socket(input_socket, operation->get_input_socket(1));
82 converter.map_output_socket(output_socket, operation->get_output_socket());
83
84 converter.add_preview(operation->get_output_socket(0));
85}
86
87} // namespace blender::compositor
@ CMP_NODE_FILTER_PREWITT
@ CMP_NODE_FILTER_SHARP_BOX
@ CMP_NODE_FILTER_KIRSCH
@ CMP_NODE_FILTER_LAPLACE
@ CMP_NODE_FILTER_SHARP_DIAMOND
@ CMP_NODE_FILTER_SOFT
@ CMP_NODE_FILTER_SOBEL
@ CMP_NODE_FILTER_SHADOW
Overall context of the compositor.
void set3x3Filter(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9)
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
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
NodeOperationOutput * get_output_socket(unsigned int index=0)
NodeOperationInput * get_input_socket(unsigned int index)
NodeOutput are sockets that can send data/input.
Definition COM_Node.h:239
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