Blender  V3.3
COM_ColorBalanceNode.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_ColorBalanceNode.h"
7 
8 namespace blender::compositor {
9 
10 ColorBalanceNode::ColorBalanceNode(bNode *editor_node) : Node(editor_node)
11 {
12  /* pass */
13 }
14 
16  const CompositorContext & /*context*/) const
17 {
18  bNode *node = this->get_bnode();
19  NodeColorBalance *n = (NodeColorBalance *)node->storage;
20 
21  NodeInput *input_socket = this->get_input_socket(0);
22  NodeInput *input_image_socket = this->get_input_socket(1);
23  NodeOutput *output_socket = this->get_output_socket(0);
24 
25  NodeOperation *operation;
26  if (node->custom1 == 0) {
28 
29  float lift_lgg[3], gamma_inv[3];
30  for (int c = 0; c < 3; c++) {
31  lift_lgg[c] = 2.0f - n->lift[c];
32  gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f;
33  }
34 
35  operationLGG->set_gain(n->gain);
36  operationLGG->set_lift(lift_lgg);
37  operationLGG->set_gamma_inv(gamma_inv);
38  operation = operationLGG;
39  }
40  else {
42 
43  float offset[3];
45  add_v3_v3(offset, n->offset);
46 
47  operationCDL->set_offset(offset);
48  operationCDL->set_power(n->power);
49  operationCDL->set_slope(n->slope);
50  operation = operationCDL;
51  }
52  converter.add_operation(operation);
53 
54  converter.map_input_socket(input_socket, operation->get_input_socket(0));
55  converter.map_input_socket(input_image_socket, operation->get_input_socket(1));
56  converter.map_output_socket(output_socket, operation->get_output_socket(0));
57 }
58 
59 } // 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])
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
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:190
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:238
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
OperationNode * node
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
static unsigned c
Definition: RandGen.cpp:83