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-08-13 10:15:28 +0300
committerManuel Castilla <manzanillawork@gmail.com>2021-08-13 10:15:28 +0300
commit70cc988a907713cd1d0883e5ed5ad81b8de7a78e (patch)
treef91e1b0c953a7ee0f761dd04b3bce90c23cdb509 /source/blender
parent1747c679ee5fc1189c7d3266768c594a0a46e3bc (diff)
Compositor: Full frame Channel Key node
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.cc33
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.h8
2 files changed, 39 insertions, 2 deletions
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cc b/source/blender/compositor/operations/COM_ChannelMatteOperation.cc
index ec4331dc231..32371885a84 100644
--- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cc
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cc
@@ -121,4 +121,37 @@ void ChannelMatteOperation::executePixelSampled(float output[4],
output[0] = MIN2(alpha, inColor[3]);
}
+void ChannelMatteOperation::update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs)
+{
+ for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
+ const float *color = it.in(0);
+
+ /* Matte operation. */
+ float alpha = color[this->m_ids[0]] - MAX2(color[this->m_ids[1]], color[this->m_ids[2]]);
+
+ /* Flip because 0.0 is transparent, not 1.0. */
+ alpha = 1.0f - alpha;
+
+ /* Test range. */
+ if (alpha > m_limit_max) {
+ alpha = color[3]; /* Whatever it was prior. */
+ }
+ else if (alpha < m_limit_min) {
+ alpha = 0.0f;
+ }
+ else { /* Blend. */
+ alpha = (alpha - m_limit_min) / m_limit_range;
+ }
+
+ /* Store matte(alpha) value in [0] to go with
+ * COM_SetAlphaMultiplyOperation and the Value output.
+ */
+
+ /* Don't make something that was more transparent less transparent. */
+ *it.out = MIN2(alpha, color[3]);
+ }
+}
+
} // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.h b/source/blender/compositor/operations/COM_ChannelMatteOperation.h
index 6e9dcccd36e..ba50105dd3b 100644
--- a/source/blender/compositor/operations/COM_ChannelMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.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 ChannelMatteOperation : public NodeOperation {
+class ChannelMatteOperation : public MultiThreadedOperation {
private:
SocketReader *m_inputImageProgram;
@@ -71,6 +71,10 @@ class ChannelMatteOperation : public NodeOperation {
this->m_limit_channel = nodeChroma->channel;
this->m_matte_channel = custom2;
}
+
+ void update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs) override;
};
} // namespace blender::compositor