Blender  V3.3
COM_InvertOperation.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_InvertOperation.h"
5 
6 namespace blender::compositor {
7 
9 {
13  input_value_program_ = nullptr;
14  input_color_program_ = nullptr;
15  color_ = true;
16  alpha_ = false;
18  flags_.can_be_constant = true;
19 }
21 {
22  input_value_program_ = this->get_input_socket_reader(0);
23  input_color_program_ = this->get_input_socket_reader(1);
24 }
25 
27  float x,
28  float y,
30 {
31  float input_value[4];
32  float input_color[4];
33  input_value_program_->read_sampled(input_value, x, y, sampler);
34  input_color_program_->read_sampled(input_color, x, y, sampler);
35 
36  const float value = input_value[0];
37  const float inverted_value = 1.0f - value;
38 
39  if (color_) {
40  output[0] = (1.0f - input_color[0]) * value + input_color[0] * inverted_value;
41  output[1] = (1.0f - input_color[1]) * value + input_color[1] * inverted_value;
42  output[2] = (1.0f - input_color[2]) * value + input_color[2] * inverted_value;
43  }
44  else {
45  copy_v3_v3(output, input_color);
46  }
47 
48  if (alpha_) {
49  output[3] = (1.0f - input_color[3]) * value + input_color[3] * inverted_value;
50  }
51  else {
52  output[3] = input_color[3];
53  }
54 }
55 
57 {
58  input_value_program_ = nullptr;
59  input_color_program_ = nullptr;
60 }
61 
63  const rcti &area,
65 {
66  for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
67  const float value = *it.in(0);
68  const float inverted_value = 1.0f - value;
69  const float *color = it.in(1);
70 
71  if (color_) {
72  it.out[0] = (1.0f - color[0]) * value + color[0] * inverted_value;
73  it.out[1] = (1.0f - color[1]) * value + color[1] * inverted_value;
74  it.out[2] = (1.0f - color[2]) * value + color[2] * inverted_value;
75  }
76  else {
77  copy_v3_v3(it.out, color);
78  }
79 
80  if (alpha_) {
81  it.out[3] = (1.0f - color[3]) * value + color[3] * inverted_value;
82  }
83  else {
84  it.out[3] = color[3];
85  }
86  }
87 }
88 
89 } // namespace blender::compositor
MINLINE void copy_v3_v3(float r[3], const float a[3])
_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 execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) 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)
void set_canvas_input_index(unsigned int index)
set the index of the input socket that will determine the canvas of this operation
depth_tx sampler(1, ImageType::FLOAT_2D, "combined_tx") .sampler(2
ccl_global KernelShaderEvalInput ccl_global float * output
static void area(int d1, int d2, int e1, int e2, float weights[2])
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator
static bNodeSocketTemplate inputs[]