Blender  V3.3
COM_ColorSpillOperation.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
5 #define AVG(a, b) ((a + b) / 2)
6 
7 namespace blender::compositor {
8 
10 {
14 
15  input_image_reader_ = nullptr;
16  input_fac_reader_ = nullptr;
17  spill_channel_ = 1; /* GREEN */
18  spill_method_ = 0;
19  flags_.can_be_constant = true;
20 }
21 
23 {
26  if (spill_channel_ == 0) {
27  rmut_ = -1.0f;
28  gmut_ = 1.0f;
29  bmut_ = 1.0f;
30  channel2_ = 1;
31  channel3_ = 2;
32  if (settings_->unspill == 0) {
33  settings_->uspillr = 1.0f;
34  settings_->uspillg = 0.0f;
35  settings_->uspillb = 0.0f;
36  }
37  }
38  else if (spill_channel_ == 1) {
39  rmut_ = 1.0f;
40  gmut_ = -1.0f;
41  bmut_ = 1.0f;
42  channel2_ = 0;
43  channel3_ = 2;
44  if (settings_->unspill == 0) {
45  settings_->uspillr = 0.0f;
46  settings_->uspillg = 1.0f;
47  settings_->uspillb = 0.0f;
48  }
49  }
50  else {
51  rmut_ = 1.0f;
52  gmut_ = 1.0f;
53  bmut_ = -1.0f;
54 
55  channel2_ = 0;
56  channel3_ = 1;
57  if (settings_->unspill == 0) {
58  settings_->uspillr = 0.0f;
59  settings_->uspillg = 0.0f;
60  settings_->uspillb = 1.0f;
61  }
62  }
63 }
64 
66 {
67  input_image_reader_ = nullptr;
68  input_fac_reader_ = nullptr;
69 }
70 
72  float x,
73  float y,
75 {
76  float fac[4];
77  float input[4];
80  float rfac = MIN2(1.0f, fac[0]);
81  float map;
82 
83  switch (spill_method_) {
84  case 0: /* simple */
86  break;
87  default: /* average */
88  map = rfac * (input[spill_channel_] -
90  break;
91  }
92 
93  if (map > 0.0f) {
94  output[0] = input[0] + rmut_ * (settings_->uspillr * map);
95  output[1] = input[1] + gmut_ * (settings_->uspillg * map);
96  output[2] = input[2] + bmut_ * (settings_->uspillb * map);
97  output[3] = input[3];
98  }
99  else {
101  }
102 }
103 
105  const rcti &area,
107 {
108  for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
109  const float *color = it.in(0);
110  const float factor = MIN2(1.0f, *it.in(1));
111 
112  float map;
113  switch (spill_method_) {
114  case 0: /* simple */
116  break;
117  default: /* average */
118  map = factor * (color[spill_channel_] -
120  break;
121  }
122 
123  if (map > 0.0f) {
124  it.out[0] = color[0] + rmut_ * (settings_->uspillr * map);
125  it.out[1] = color[1] + gmut_ * (settings_->uspillg * map);
126  it.out[2] = color[2] + bmut_ * (settings_->uspillb * map);
127  it.out[3] = color[3];
128  }
129  else {
130  copy_v4_v4(it.out, color);
131  }
132  }
133 }
134 
135 } // namespace blender::compositor
MINLINE void copy_v4_v4(float r[4], const float a[4])
#define MIN2(a, b)
#define AVG(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
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
a MemoryBuffer contains access to the data of a chunk
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)
depth_tx sampler(1, ImageType::FLOAT_2D, "combined_tx") .sampler(2
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_global KernelShaderEvalInput * input
static void area(int d1, int d2, int e1, int e2, float weights[2])
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator
static bNodeSocketTemplate inputs[]
SocketIndexByIdentifierMap * map