Blender V4.3
COM_GlareThresholdOperation.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
5#include "BLI_math_base.hh"
6#include "BLI_math_color.h"
7#include "BLI_utildefines.h"
8
10
12
13namespace blender::compositor {
14
22
23void GlareThresholdOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
24{
25 NodeOperation::determine_canvas(preferred_area, r_area);
26 const int width = BLI_rcti_size_x(&r_area) / (1 << settings_->quality);
27 const int height = BLI_rcti_size_y(&r_area) / (1 << settings_->quality);
28 r_area.xmax = r_area.xmin + width;
29 r_area.ymax = r_area.ymin + height;
30}
31
33 const rcti &area,
35{
36 const float threshold = settings_->threshold;
37 for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
38 float4 hsva;
39 rgb_to_hsv_v(it.in(0), hsva);
40
41 hsva.z = math::max(0.0f, hsva.z - threshold);
42
43 hsv_to_rgb_v(hsva, it.out);
44 CLAMP3_MIN(it.out, 0.0f);
45 it.out[3] = 1.0f;
46 }
47}
48
49} // namespace blender::compositor
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
Definition math_color.cc:57
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.h:193
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.h:189
#define CLAMP3_MIN(vec, b)
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
void determine_canvas(const rcti &preferred_area, rcti &r_area) 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)
virtual void determine_canvas(const rcti &preferred_area, rcti &r_area)
@ FitAny
Fit the width or the height of the input image to the width or height of the working area of the node...
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator
T max(const T &a, const T &b)
int ymin
int ymax
int xmin
int xmax