Blender  V3.3
COM_ZCombineNode.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
4 #include "COM_ZCombineNode.h"
5 
9 
10 namespace blender::compositor {
11 
13  const CompositorContext & /*context*/) const
14 {
15  if (this->get_bnode()->custom2) {
16  ZCombineOperation *operation = nullptr;
17  if (this->get_bnode()->custom1) {
18  operation = new ZCombineAlphaOperation();
19  }
20  else {
21  operation = new ZCombineOperation();
22  }
23  converter.add_operation(operation);
24 
25  converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
26  converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
27  converter.map_input_socket(get_input_socket(2), operation->get_input_socket(2));
28  converter.map_input_socket(get_input_socket(3), operation->get_input_socket(3));
29  converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
30 
31  MathMinimumOperation *zoperation = new MathMinimumOperation();
32  converter.add_operation(zoperation);
33 
34  converter.map_input_socket(get_input_socket(1), zoperation->get_input_socket(0));
35  converter.map_input_socket(get_input_socket(3), zoperation->get_input_socket(1));
36  converter.map_output_socket(get_output_socket(1), zoperation->get_output_socket());
37  }
38  else {
39  /* XXX custom1 is "use_alpha", what on earth is this supposed to do here?!? */
40  /* not full anti alias, use masking for Z combine. be aware it uses anti aliasing. */
41 
42  /* Step 1 create mask. */
43  NodeOperation *maskoperation;
44  if (this->get_bnode()->custom1) {
45  maskoperation = new MathGreaterThanOperation();
46  }
47  else {
48  maskoperation = new MathLessThanOperation();
49  }
50  converter.add_operation(maskoperation);
51 
52  converter.map_input_socket(get_input_socket(1), maskoperation->get_input_socket(0));
53  converter.map_input_socket(get_input_socket(3), maskoperation->get_input_socket(1));
54 
55  /* Step 2 anti alias mask bit of an expensive operation, but does the trick. */
56  AntiAliasOperation *antialiasoperation = new AntiAliasOperation();
57  converter.add_operation(antialiasoperation);
58 
59  converter.add_link(maskoperation->get_output_socket(),
60  antialiasoperation->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(antialiasoperation->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 
74  MathMinimumOperation *zoperation = new MathMinimumOperation();
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
AntiAlias operations it only supports anti aliasing on BW buffers.
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:84
bNode * get_bnode() const
get the reference to the SDNA bNode struct
Definition: COM_Node.h:64
NodeInput * get_input_socket(unsigned int index) const
Definition: COM_Node.cc:89
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
short custom1