Blender V4.3
COM_ColorBalanceASCCDLOperation.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
6
7namespace blender::compositor {
8
9inline float colorbalance_cdl(float in, float offset, float power, float slope)
10{
11 float x = in * slope + offset;
12
13 /* prevent NaN */
14 if (x < 0.0f) {
15 x = 0.0f;
16 }
17
18 return powf(x, power);
19}
20
29
31{
32 for (; p.out < p.row_end; p.next()) {
33 const float *in_factor = p.ins[0];
34 const float *in_color = p.ins[1];
35 const float fac = std::min(1.0f, in_factor[0]);
36 const float fac_m = 1.0f - fac;
37 p.out[0] = fac_m * in_color[0] +
38 fac * colorbalance_cdl(in_color[0], offset_[0], power_[0], slope_[0]);
39 p.out[1] = fac_m * in_color[1] +
40 fac * colorbalance_cdl(in_color[1], offset_[1], power_[1], slope_[1]);
41 p.out[2] = fac_m * in_color[2] +
42 fac * colorbalance_cdl(in_color[2], offset_[2], power_[2], slope_[2]);
43 p.out[3] = in_color[3];
44 }
45}
46
47} // namespace blender::compositor
void add_output_socket(DataType datatype)
void add_input_socket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
void set_canvas_input_index(unsigned int index)
set the index of the input socket that will determine the canvas of this operation
#define powf(x, y)
ccl_device_inline float2 power(float2 v, float e)
float colorbalance_cdl(float in, float offset, float power, float slope)