Blender V4.3
COM_ColorMatteOperation.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
7namespace blender::compositor {
8
17
19 const rcti &area,
21{
22 const float hue = settings_->t1;
23 const float sat = settings_->t2;
24 const float val = settings_->t3;
25 for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
26 const float *in_color = it.in(0);
27 const float *in_key = it.in(1);
28
29 /* Store matte(alpha) value in [0] to go with
30 * COM_SetAlphaMultiplyOperation and the Value output.
31 */
32
33 float h_wrap;
34 if (
35 /* Do hue last because it needs to wrap, and does some more checks. */
36
37 /* #sat */ (fabsf(in_color[1] - in_key[1]) < sat) &&
38 /* #val */ (fabsf(in_color[2] - in_key[2]) < val) &&
39
40 /* Multiply by 2 because it wraps on both sides of the hue,
41 * otherwise 0.5 would key all hue's. */
42
43 /* #hue */
44 ((h_wrap = 2.0f * fabsf(in_color[0] - in_key[0])) < hue || (2.0f - h_wrap) < hue))
45 {
46 it.out[0] = 0.0f; /* Make transparent. */
47 }
48
49 else { /* Pixel is outside key color. */
50 it.out[0] = in_color[3]; /* Make pixel just as transparent as it was before. */
51 }
52 }
53}
54
55} // namespace blender::compositor
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)
#define fabsf(x)
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator