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_DifferenceMatteOperation.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_DifferenceMatteOperation.cc')
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cc b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cc
index 0acdfc1651f..31714b03b06 100644
--- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cc
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cc
@@ -29,6 +29,7 @@ DifferenceMatteOperation::DifferenceMatteOperation()
this->m_inputImage1Program = nullptr;
this->m_inputImage2Program = nullptr;
+ flags.can_be_constant = true;
}
void DifferenceMatteOperation::initExecution()
@@ -86,4 +87,44 @@ void DifferenceMatteOperation::executePixelSampled(float output[4],
}
}
+void DifferenceMatteOperation::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 *color1 = it.in(0);
+ const float *color2 = it.in(1);
+
+ float difference = (fabsf(color2[0] - color1[0]) + fabsf(color2[1] - color1[1]) +
+ fabsf(color2[2] - color1[2]));
+
+ /* Average together the distances. */
+ difference = difference / 3.0f;
+
+ const float tolerance = m_settings->t1;
+ const float falloff = m_settings->t2;
+
+ /* Make 100% transparent. */
+ if (difference <= tolerance) {
+ it.out[0] = 0.0f;
+ }
+ /* In the falloff region, make partially transparent. */
+ else if (difference <= falloff + tolerance) {
+ difference = difference - tolerance;
+ const float alpha = difference / falloff;
+ /* Only change if more transparent than before. */
+ if (alpha < color1[3]) {
+ it.out[0] = alpha;
+ }
+ else { /* Leave as before. */
+ it.out[0] = color1[3];
+ }
+ }
+ else {
+ /* Foreground object. */
+ it.out[0] = color1[3];
+ }
+ }
+}
+
} // namespace blender::compositor