Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/compositor/operations/COM_GlareThresholdOperation.cc')
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.cc31
1 files changed, 26 insertions, 5 deletions
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cc b/source/blender/compositor/operations/COM_GlareThresholdOperation.cc
index 1d3402f5b7b..1bf7cf5ae07 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cc
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cc
@@ -30,12 +30,13 @@ GlareThresholdOperation::GlareThresholdOperation()
this->m_inputProgram = nullptr;
}
-void GlareThresholdOperation::determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void GlareThresholdOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{
- NodeOperation::determineResolution(resolution, preferredResolution);
- resolution[0] = resolution[0] / (1 << this->m_settings->quality);
- resolution[1] = resolution[1] / (1 << this->m_settings->quality);
+ NodeOperation::determine_canvas(preferred_area, r_area);
+ const int width = BLI_rcti_size_x(&r_area) / (1 << this->m_settings->quality);
+ const int height = BLI_rcti_size_y(&r_area) / (1 << this->m_settings->quality);
+ r_area.xmax = r_area.xmin + width;
+ r_area.ymax = r_area.ymin + height;
}
void GlareThresholdOperation::initExecution()
@@ -70,4 +71,24 @@ void GlareThresholdOperation::deinitExecution()
this->m_inputProgram = nullptr;
}
+void GlareThresholdOperation::update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs)
+{
+ const float threshold = this->m_settings->threshold;
+ for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
+ const float *color = it.in(0);
+ if (IMB_colormanagement_get_luminance(color) >= threshold) {
+ it.out[0] = color[0] - threshold;
+ it.out[1] = color[1] - threshold;
+ it.out[2] = color[2] - threshold;
+
+ CLAMP3_MIN(it.out, 0.0f);
+ }
+ else {
+ zero_v3(it.out);
+ }
+ }
+}
+
} // namespace blender::compositor