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
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its hue
#define output
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
static blender::bke::bNodeSocketTemplate inputs[]