Blender V4.3
COM_KeyingDespillOperation.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BLI_math_geom.h"
6
8
9namespace blender::compositor {
10
22
24 const rcti &area,
26{
27 for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
28 const float *pixel_color = it.in(0);
29 const float *screen_color = it.in(1);
30
31 const int screen_primary_channel = max_axis_v3(screen_color);
32 const int other_1 = (screen_primary_channel + 1) % 3;
33 const int other_2 = (screen_primary_channel + 2) % 3;
34
35 const int min_channel = std::min(other_1, other_2);
36 const int max_channel = std::max(other_1, other_2);
37
38 const float average_value = color_balance_ * pixel_color[min_channel] +
39 (1.0f - color_balance_) * pixel_color[max_channel];
40 const float amount = (pixel_color[screen_primary_channel] - average_value);
41
42 copy_v4_v4(it.out, pixel_color);
43
44 const float amount_despill = despill_factor_ * amount;
45 if (amount_despill > 0.0f) {
46 it.out[screen_primary_channel] = pixel_color[screen_primary_channel] - amount_despill;
47 }
48 }
49}
50
51} // namespace blender::compositor
MINLINE int max_axis_v3(const float vec[3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
a MemoryBuffer contains access to the data
void add_output_socket(DataType datatype)
void add_input_socket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator