[Bf-blender-cvs] [591e46c3355] compositor-full-frame: Compositor: Full frame Color Key node
Manuel Castilla
noreply at git.blender.org
Fri Aug 13 18:24:17 CEST 2021
Commit: 591e46c3355ca81d611c6a9e39f6581489fc4f57
Author: Manuel Castilla
Date: Fri Aug 13 11:08:58 2021 +0200
Branches: compositor-full-frame
https://developer.blender.org/rB591e46c3355ca81d611c6a9e39f6581489fc4f57
Compositor: Full frame Color Key node
===================================================================
M source/blender/compositor/operations/COM_ColorMatteOperation.cc
M source/blender/compositor/operations/COM_ColorMatteOperation.h
===================================================================
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cc b/source/blender/compositor/operations/COM_ColorMatteOperation.cc
index ddfbf415d9c..27c0c0cc071 100644
--- a/source/blender/compositor/operations/COM_ColorMatteOperation.cc
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cc
@@ -82,4 +82,40 @@ void ColorMatteOperation::executePixelSampled(float output[4],
}
}
+void ColorMatteOperation::update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs)
+{
+ const float hue = m_settings->t1;
+ const float sat = m_settings->t2;
+ const float val = m_settings->t3;
+ for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
+ const float *in_color = it.in(0);
+ const float *in_key = it.in(1);
+
+ /* Store matte(alpha) value in [0] to go with
+ * COM_SetAlphaMultiplyOperation and the Value output.
+ */
+
+ float h_wrap;
+ if (
+ /* Do hue last because it needs to wrap, and does some more checks. */
+
+ /* #sat */ (fabsf(in_color[1] - in_key[1]) < sat) &&
+ /* #val */ (fabsf(in_color[2] - in_key[2]) < val) &&
+
+ /* Multiply by 2 because it wraps on both sides of the hue,
+ * otherwise 0.5 would key all hue's. */
+
+ /* #hue */
+ ((h_wrap = 2.0f * fabsf(in_color[0] - in_key[0])) < hue || (2.0f - h_wrap) < hue)) {
+ it.out[0] = 0.0f; /* Make transparent. */
+ }
+
+ else { /* Pixel is outside key color. */
+ it.out[0] = in_color[3]; /* Make pixel just as transparent as it was before. */
+ }
+ }
+}
+
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.h b/source/blender/compositor/operations/COM_ColorMatteOperation.h
index 439a3b0741d..49d06e62e65 100644
--- a/source/blender/compositor/operations/COM_ColorMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.h
@@ -18,7 +18,7 @@
#pragma once
-#include "COM_MixOperation.h"
+#include "COM_MultiThreadedOperation.h"
namespace blender::compositor {
@@ -26,7 +26,7 @@ namespace blender::compositor {
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
-class ColorMatteOperation : public NodeOperation {
+class ColorMatteOperation : public MultiThreadedOperation {
private:
NodeChroma *m_settings;
SocketReader *m_inputImageProgram;
@@ -50,6 +50,10 @@ class ColorMatteOperation : public NodeOperation {
{
this->m_settings = nodeChroma;
}
+
+ void update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs) override;
};
} // namespace blender::compositor
More information about the Bf-blender-cvs
mailing list