Blender  V3.3
COM_ColorBalanceASCCDLOperation.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
5 
6 namespace blender::compositor {
7 
8 inline float colorbalance_cdl(float in, float offset, float power, float slope)
9 {
10  float x = in * slope + offset;
11 
12  /* prevent NaN */
13  if (x < 0.0f) {
14  x = 0.0f;
15  }
16 
17  return powf(x, power);
18 }
19 
21 {
25  input_value_operation_ = nullptr;
26  input_color_operation_ = nullptr;
27  this->set_canvas_input_index(1);
28  flags_.can_be_constant = true;
29 }
30 
32 {
35 }
36 
38  float x,
39  float y,
41 {
42  float input_color[4];
43  float value[4];
44 
47 
48  float fac = value[0];
49  fac = MIN2(1.0f, fac);
50  const float mfac = 1.0f - fac;
51 
52  output[0] = mfac * input_color[0] +
53  fac * colorbalance_cdl(input_color[0], offset_[0], power_[0], slope_[0]);
54  output[1] = mfac * input_color[1] +
55  fac * colorbalance_cdl(input_color[1], offset_[1], power_[1], slope_[1]);
56  output[2] = mfac * input_color[2] +
57  fac * colorbalance_cdl(input_color[2], offset_[2], power_[2], slope_[2]);
58  output[3] = input_color[3];
59 }
60 
62 {
63  for (; p.out < p.row_end; p.next()) {
64  const float *in_factor = p.ins[0];
65  const float *in_color = p.ins[1];
66  const float fac = MIN2(1.0f, in_factor[0]);
67  const float fac_m = 1.0f - fac;
68  p.out[0] = fac_m * in_color[0] +
69  fac * colorbalance_cdl(in_color[0], offset_[0], power_[0], slope_[0]);
70  p.out[1] = fac_m * in_color[1] +
71  fac * colorbalance_cdl(in_color[1], offset_[1], power_[1], slope_[1]);
72  p.out[2] = fac_m * in_color[2] +
73  fac * colorbalance_cdl(in_color[2], offset_[2], power_[2], slope_[2]);
74  p.out[3] = in_color[3];
75  }
76 }
77 
79 {
80  input_value_operation_ = nullptr;
81  input_color_operation_ = nullptr;
82 }
83 
84 } // namespace blender::compositor
#define MIN2(a, b)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
void add_output_socket(DataType datatype)
SocketReader * get_input_socket_reader(unsigned int index)
void read_sampled(float result[4], float x, float y, PixelSampler sampler)
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)
Definition: cuda/compat.h:103
depth_tx sampler(1, ImageType::FLOAT_2D, "combined_tx") .sampler(2
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
float colorbalance_cdl(float in, float offset, float power, float slope)