Blender V4.3
COM_ZCombineNode.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_ZCombineNode.h"
6
8#include "COM_SMAAOperation.h"
10
11namespace blender::compositor {
12
14 const CompositorContext & /*context*/) const
15{
16 if (this->get_bnode()->custom2) {
17 ZCombineOperation *operation = nullptr;
18 if (this->get_bnode()->custom1) {
19 operation = new ZCombineAlphaOperation();
20 }
21 else {
22 operation = new ZCombineOperation();
23 }
24 converter.add_operation(operation);
25
26 converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
27 converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
28 converter.map_input_socket(get_input_socket(2), operation->get_input_socket(2));
29 converter.map_input_socket(get_input_socket(3), operation->get_input_socket(3));
30 converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
31
33 converter.add_operation(zoperation);
34
35 converter.map_input_socket(get_input_socket(1), zoperation->get_input_socket(0));
36 converter.map_input_socket(get_input_socket(3), zoperation->get_input_socket(1));
37 converter.map_output_socket(get_output_socket(1), zoperation->get_output_socket());
38 }
39 else {
40 /* XXX custom1 is "use_alpha", what on earth is this supposed to do here?!? */
41 /* not full anti alias, use masking for Z combine. be aware it uses anti aliasing. */
42
43 /* Step 1 create mask. */
44 NodeOperation *maskoperation;
45 if (this->get_bnode()->custom1) {
46 maskoperation = new MathGreaterThanOperation();
47 }
48 else {
49 maskoperation = new MathLessThanOperation();
50 }
51 converter.add_operation(maskoperation);
52
53 converter.map_input_socket(get_input_socket(1), maskoperation->get_input_socket(0));
54 converter.map_input_socket(get_input_socket(3), maskoperation->get_input_socket(1));
55
56 /* Step 2 anti alias mask bit of an expensive operation, but does the trick. */
57 SMAAOperation *smaa_operation = new SMAAOperation();
58 converter.add_operation(smaa_operation);
59
60 converter.add_link(maskoperation->get_output_socket(), smaa_operation->get_input_socket(0));
61
62 /* use mask to blend between the input colors. */
63 ZCombineMaskOperation *zcombineoperation = this->get_bnode()->custom1 ?
66 converter.add_operation(zcombineoperation);
67
68 converter.add_link(smaa_operation->get_output_socket(),
69 zcombineoperation->get_input_socket(0));
70 converter.map_input_socket(get_input_socket(0), zcombineoperation->get_input_socket(1));
71 converter.map_input_socket(get_input_socket(2), zcombineoperation->get_input_socket(2));
72 converter.map_output_socket(get_output_socket(0), zcombineoperation->get_output_socket());
73
75 converter.add_operation(zoperation);
76
77 converter.map_input_socket(get_input_socket(1), zoperation->get_input_socket(0));
78 converter.map_input_socket(get_input_socket(3), zoperation->get_input_socket(1));
79 converter.map_output_socket(get_output_socket(1), zoperation->get_output_socket());
80 }
81}
82
83} // namespace blender::compositor
Overall context of the compositor.
void add_link(NodeOperationOutput *from, NodeOperationInput *to)
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
void add_operation(NodeOperation *operation)
void map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket)
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
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
int16_t custom1