Blender V4.3
COM_ColorSpillOperation.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#define AVG(a, b) ((a + b) / 2)
7
8namespace blender::compositor {
9
20
22{
23 if (spill_channel_ == 0) {
24 rmut_ = -1.0f;
25 gmut_ = 1.0f;
26 bmut_ = 1.0f;
27 channel2_ = 1;
28 channel3_ = 2;
29 if (settings_->unspill == 0) {
30 settings_->uspillr = 1.0f;
31 settings_->uspillg = 0.0f;
32 settings_->uspillb = 0.0f;
33 }
34 }
35 else if (spill_channel_ == 1) {
36 rmut_ = 1.0f;
37 gmut_ = -1.0f;
38 bmut_ = 1.0f;
39 channel2_ = 0;
40 channel3_ = 2;
41 if (settings_->unspill == 0) {
42 settings_->uspillr = 0.0f;
43 settings_->uspillg = 1.0f;
44 settings_->uspillb = 0.0f;
45 }
46 }
47 else {
48 rmut_ = 1.0f;
49 gmut_ = 1.0f;
50 bmut_ = -1.0f;
51
52 channel2_ = 0;
53 channel3_ = 1;
54 if (settings_->unspill == 0) {
55 settings_->uspillr = 0.0f;
56 settings_->uspillg = 0.0f;
57 settings_->uspillb = 1.0f;
58 }
59 }
60}
61
63 const rcti &area,
65{
66 for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
67 const float *color = it.in(0);
68 const float factor = std::min(1.0f, *it.in(1));
69
70 float map;
71 switch (spill_method_) {
72 case 0: /* simple */
73 map = factor * (color[spill_channel_] - (settings_->limscale * color[settings_->limchan]));
74 break;
75 default: /* average */
76 map = factor * (color[spill_channel_] -
77 (settings_->limscale * AVG(color[channel2_], color[channel3_])));
78 break;
79 }
80
81 if (map > 0.0f) {
82 it.out[0] = color[0] + rmut_ * (settings_->uspillr * map);
83 it.out[1] = color[1] + gmut_ * (settings_->uspillg * map);
84 it.out[2] = color[2] + bmut_ * (settings_->uspillb * map);
85 it.out[3] = color[3];
86 }
87 else {
88 copy_v4_v4(it.out, color);
89 }
90 }
91}
92
93} // namespace blender::compositor
MINLINE void copy_v4_v4(float r[4], const float a[4])
#define AVG(a, b)
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