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:
authorManuel Castilla <manzanillawork@gmail.com>2021-09-28 20:33:26 +0300
committerManuel Castilla <manzanillawork@gmail.com>2021-09-28 23:00:17 +0300
commit283d76a70dba69665d08039a0a7c675c9efc7110 (patch)
tree1536dd01699558f7924e110fded3e56bd303d719
parent0830211c952983075f420175904fa10edf7b7f08 (diff)
Compositor: Full frame Glare node
Part of T88150.
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.cc34
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.h10
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.cc20
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.h7
4 files changed, 69 insertions, 2 deletions
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cc b/source/blender/compositor/operations/COM_GlareBaseOperation.cc
index 90755d9f27a..cd4607b1dde 100644
--- a/source/blender/compositor/operations/COM_GlareBaseOperation.cc
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cc
@@ -26,6 +26,8 @@ GlareBaseOperation::GlareBaseOperation()
this->addInputSocket(DataType::Color);
this->addOutputSocket(DataType::Color);
this->m_settings = nullptr;
+ flags.is_fullframe_operation = true;
+ is_output_rendered_ = false;
}
void GlareBaseOperation::initExecution()
{
@@ -69,4 +71,36 @@ bool GlareBaseOperation::determineDependingAreaOfInterest(rcti * /*input*/,
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
+void GlareBaseOperation::get_area_of_interest(const int input_idx,
+ const rcti &UNUSED(output_area),
+ rcti &r_input_area)
+{
+ BLI_assert(input_idx == 0);
+ UNUSED_VARS_NDEBUG(input_idx);
+ r_input_area.xmin = 0;
+ r_input_area.xmax = this->getWidth();
+ r_input_area.ymin = 0;
+ r_input_area.ymax = this->getHeight();
+}
+
+void GlareBaseOperation::update_memory_buffer(MemoryBuffer *output,
+ const rcti &UNUSED(area),
+ Span<MemoryBuffer *> inputs)
+{
+ if (!is_output_rendered_) {
+ MemoryBuffer *input = inputs[0];
+ const bool is_input_inflated = input->is_a_single_elem();
+ if (is_input_inflated) {
+ input = input->inflate();
+ }
+
+ this->generateGlare(output->getBuffer(), input, m_settings);
+ is_output_rendered_ = true;
+
+ if (is_input_inflated) {
+ delete input;
+ }
+ }
+}
+
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.h b/source/blender/compositor/operations/COM_GlareBaseOperation.h
index 6dac6f5ecc7..5ca240a9e66 100644
--- a/source/blender/compositor/operations/COM_GlareBaseOperation.h
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.h
@@ -49,6 +49,8 @@ class GlareBaseOperation : public SingleThreadedOperation {
*/
NodeGlare *m_settings;
+ bool is_output_rendered_;
+
public:
/**
* Initialize the execution
@@ -68,6 +70,14 @@ class GlareBaseOperation : public SingleThreadedOperation {
ReadBufferOperation *readOperation,
rcti *output) override;
+ void get_area_of_interest(const int input_idx,
+ const rcti &output_area,
+ rcti &r_input_area) final;
+
+ void update_memory_buffer(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs) final;
+
protected:
GlareBaseOperation();
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cc b/source/blender/compositor/operations/COM_GlareThresholdOperation.cc
index f8da0b9a102..1bf7cf5ae07 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cc
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cc
@@ -71,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
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.h b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
index 1f247f58324..44f2d717c0e 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.h
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
@@ -18,12 +18,12 @@
#pragma once
-#include "COM_NodeOperation.h"
+#include "COM_MultiThreadedOperation.h"
#include "DNA_light_types.h"
namespace blender::compositor {
-class GlareThresholdOperation : public NodeOperation {
+class GlareThresholdOperation : public MultiThreadedOperation {
private:
/**
* \brief Cached reference to the inputProgram
@@ -59,6 +59,9 @@ class GlareThresholdOperation : public NodeOperation {
}
void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
+ void update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs) override;
};
} // namespace blender::compositor