Blender V4.3
COM_ColorBalanceNode.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
9
10namespace blender::compositor {
11
12ColorBalanceNode::ColorBalanceNode(bNode *editor_node) : Node(editor_node)
13{
14 /* pass */
15}
16
18 const CompositorContext & /*context*/) const
19{
20 const bNode *node = this->get_bnode();
21 NodeColorBalance *n = (NodeColorBalance *)node->storage;
22
23 NodeInput *input_socket = this->get_input_socket(0);
24 NodeInput *input_image_socket = this->get_input_socket(1);
25 NodeOutput *output_socket = this->get_output_socket(0);
26
27 NodeOperation *operation;
28 if (node->custom1 == CMP_NODE_COLOR_BALANCE_LGG) {
30
31 float lift_lgg[3], gamma_inv[3];
32 for (int c = 0; c < 3; c++) {
33 lift_lgg[c] = 2.0f - n->lift[c];
34 gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f;
35 }
36
37 operationLGG->set_gain(n->gain);
38 operationLGG->set_lift(lift_lgg);
39 operationLGG->set_gamma_inv(gamma_inv);
40 operation = operationLGG;
41 }
42 else if (node->custom1 == CMP_NODE_COLOR_BALANCE_ASC_CDL) {
44
45 float offset[3];
46 copy_v3_fl(offset, n->offset_basis);
47 add_v3_v3(offset, n->offset);
48
49 operationCDL->set_offset(offset);
50 operationCDL->set_power(n->power);
51 operationCDL->set_slope(n->slope);
52 operation = operationCDL;
53 }
54 else {
56 operation_whitepoint->set_parameters(
58 operation = operation_whitepoint;
59 }
60 converter.add_operation(operation);
61
62 converter.map_input_socket(input_socket, operation->get_input_socket(0));
63 converter.map_input_socket(input_image_socket, operation->get_input_socket(1));
64 converter.map_output_socket(output_socket, operation->get_output_socket(0));
65}
66
67} // namespace blender::compositor
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
@ CMP_NODE_COLOR_BALANCE_LGG
@ CMP_NODE_COLOR_BALANCE_ASC_CDL
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
void set_parameters(const float input_temperature, const float input_tint, const float output_temperature, const float output_tint)
Overall context of the compositor.
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)
NodeInput are sockets that can receive data/input.
Definition COM_Node.h:191
NodeOperation contains calculation logic.
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