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-23 16:30:46 +0300
committerManuel Castilla <manzanillawork@gmail.com>2021-08-23 18:09:59 +0300
commit153b45037f5d27cf125d56ebb9aa77aca53d0981 (patch)
treebcf590fc895b03efbfb090acd1fecfb1fa4f04a0 /source/blender/compositor/operations/COM_ChannelMatteOperation.cc
parentdaa7c59e38c8fe464004b3becd6956b880c38c92 (diff)
Compositor: Full frame matte nodes
Adds full frame implementation to Channel Key, Chroma Key, Color Key, Color Spill, Cryptomatte, Difference Key, Distance Key, Keying, Keying Screen and Luminance Key nodes. The other nodes in "Matte" sub-menu are submitted separately. No functional changes. Part of T88150. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D12220
Diffstat (limited to 'source/blender/compositor/operations/COM_ChannelMatteOperation.cc')
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cc b/source/blender/compositor/operations/COM_ChannelMatteOperation.cc
index ec4331dc231..65742d0cfcc 100644
--- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cc
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cc
@@ -27,6 +27,7 @@ ChannelMatteOperation::ChannelMatteOperation()
addOutputSocket(DataType::Value);
this->m_inputImageProgram = nullptr;
+ flags.can_be_constant = true;
}
void ChannelMatteOperation::initExecution()
@@ -121,4 +122,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