[Bf-blender-cvs] [9dbea1db66d] master: Compositor: Alpha Mode

Jeroen Bakker noreply at git.blender.org
Tue Jan 5 16:35:52 CET 2021


Commit: 9dbea1db66da5e277e8279811d66096751f38d29
Author: Jeroen Bakker
Date:   Tue Jan 5 16:16:18 2021 +0100
Branches: master
https://developer.blender.org/rB9dbea1db66da5e277e8279811d66096751f38d29

Compositor: Alpha Mode

{D9211} introduced pre-multiplying the color for the keying node. This
pre-multiplication should also be done by other keying nodes and should be
the default operation for alpha node.

This patch will change the logic of keying nodes (Cryptomatte Node,
Channel Matte, Chroma Matte, Color Matte, Difference Matte, Distance
Matte, Luminance Matte) and breaks old files.

The Set alpha node has a mode parameter. This parameter changes
the logic to `Apply Mask` the alpha on the RGBA channels of the input color
or only replace the alpha channel (old behavior).

The replace mode is automatically set for older files. When adding
new files the the multiply mode is set.

Reviewed By: Sergey Sharybin

Differential Revision: https://developer.blender.org/D9630

===================================================================

M	source/blender/blenloader/intern/versioning_290.c
M	source/blender/compositor/CMakeLists.txt
M	source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
M	source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
M	source/blender/compositor/nodes/COM_ColorMatteNode.cpp
M	source/blender/compositor/nodes/COM_CryptomatteNode.cpp
M	source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
M	source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
M	source/blender/compositor/nodes/COM_KeyingNode.cpp
M	source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
M	source/blender/compositor/nodes/COM_SetAlphaNode.cpp
M	source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
M	source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
M	source/blender/compositor/operations/COM_ColorMatteOperation.cpp
M	source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
M	source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
R073	source/blender/compositor/operations/COM_KeyingSetAlphaOperation.cpp	source/blender/compositor/operations/COM_SetAlphaMultiplyOperation.cpp
R080	source/blender/compositor/operations/COM_KeyingSetAlphaOperation.h	source/blender/compositor/operations/COM_SetAlphaMultiplyOperation.h
R067	source/blender/compositor/operations/COM_SetAlphaOperation.cpp	source/blender/compositor/operations/COM_SetAlphaReplaceOperation.cpp
R093	source/blender/compositor/operations/COM_SetAlphaOperation.h	source/blender/compositor/operations/COM_SetAlphaReplaceOperation.h
M	source/blender/editors/space_node/drawnode.c
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/NOD_static_types.h
M	source/blender/nodes/composite/nodes/node_composite_setalpha.c

===================================================================

diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 63ef436d8e2..de59075559d 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -1490,5 +1490,22 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
    */
   {
     /* Keep this block, even when empty. */
+    if (!DNA_struct_find(fd->filesdna, "NodeSetAlpha")) {
+      LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+        bNodeTree *nodetree = scene->nodetree;
+        if (nodetree == NULL) {
+          continue;
+        }
+
+        LISTBASE_FOREACH (bNode *, node, &nodetree->nodes) {
+          if (node->type != CMP_NODE_SETALPHA) {
+            continue;
+          }
+          NodeSetAlpha *storage = MEM_callocN(sizeof(NodeSetAlpha), "NodeSetAlpha");
+          storage->mode = CMP_NODE_SETALPHA_MODE_REPLACE_ALPHA;
+          node->storage = storage;
+        }
+      }
+    }
   }
 }
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index 26d29f72efb..19eeb90c822 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -355,8 +355,6 @@ set(SRC
   operations/COM_KeyingDespillOperation.h
   operations/COM_KeyingOperation.cpp
   operations/COM_KeyingOperation.h
-  operations/COM_KeyingSetAlphaOperation.cpp
-  operations/COM_KeyingSetAlphaOperation.h
 
   operations/COM_ColorSpillOperation.cpp
   operations/COM_ColorSpillOperation.h
@@ -461,8 +459,10 @@ set(SRC
   operations/COM_MapRangeOperation.h
   operations/COM_MapValueOperation.cpp
   operations/COM_MapValueOperation.h
-  operations/COM_SetAlphaOperation.cpp
-  operations/COM_SetAlphaOperation.h
+  operations/COM_SetAlphaMultiplyOperation.cpp
+  operations/COM_SetAlphaMultiplyOperation.h
+  operations/COM_SetAlphaReplaceOperation.cpp
+  operations/COM_SetAlphaReplaceOperation.h
 
   # Distort operation
   operations/COM_DisplaceOperation.cpp
diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
index c927865489b..598cd7b7745 100644
--- a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
@@ -20,7 +20,7 @@
 #include "BKE_node.h"
 #include "COM_ChannelMatteOperation.h"
 #include "COM_ConvertOperation.h"
-#include "COM_SetAlphaOperation.h"
+#include "COM_SetAlphaMultiplyOperation.h"
 
 ChannelMatteNode::ChannelMatteNode(bNode *editorNode) : Node(editorNode)
 {
@@ -64,7 +64,7 @@ void ChannelMatteNode::convertToOperations(NodeConverter &converter,
   operation->setSettings((NodeChroma *)node->storage, node->custom2);
   converter.addOperation(operation);
 
-  SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+  SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation();
   converter.addOperation(operationAlpha);
 
   if (convert != nullptr) {
diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
index 75d161d7d4d..83e88b35f92 100644
--- a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
@@ -20,7 +20,7 @@
 #include "BKE_node.h"
 #include "COM_ChromaMatteOperation.h"
 #include "COM_ConvertOperation.h"
-#include "COM_SetAlphaOperation.h"
+#include "COM_SetAlphaMultiplyOperation.h"
 
 ChromaMatteNode::ChromaMatteNode(bNode *editorNode) : Node(editorNode)
 {
@@ -48,7 +48,7 @@ void ChromaMatteNode::convertToOperations(NodeConverter &converter,
   operation->setSettings((NodeChroma *)editorsnode->storage);
   converter.addOperation(operation);
 
-  SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+  SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation();
   converter.addOperation(operationAlpha);
 
   converter.mapInputSocket(inputSocketImage, operationRGBToYCC_Image->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
index f5cb84975e9..865eee5427f 100644
--- a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
@@ -20,7 +20,7 @@
 #include "BKE_node.h"
 #include "COM_ColorMatteOperation.h"
 #include "COM_ConvertOperation.h"
-#include "COM_SetAlphaOperation.h"
+#include "COM_SetAlphaMultiplyOperation.h"
 
 ColorMatteNode::ColorMatteNode(bNode *editorNode) : Node(editorNode)
 {
@@ -46,7 +46,7 @@ void ColorMatteNode::convertToOperations(NodeConverter &converter,
   operation->setSettings((NodeChroma *)editorsnode->storage);
   converter.addOperation(operation);
 
-  SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+  SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation();
   converter.addOperation(operationAlpha);
 
   converter.mapInputSocket(inputSocketImage, operationRGBToHSV_Image->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
index 7ca4e1f76fc..27ef98af8f3 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
@@ -19,13 +19,13 @@
 #include "COM_CryptomatteNode.h"
 #include "COM_ConvertOperation.h"
 #include "COM_CryptomatteOperation.h"
-#include "COM_SetAlphaOperation.h"
 
 #include "BLI_assert.h"
 #include "BLI_hash_mm3.h"
 #include "BLI_listbase.h"
 #include "BLI_string.h"
 
+#include "COM_SetAlphaMultiplyOperation.h"
 #include <iterator>
 
 CryptomatteNode::CryptomatteNode(bNode *editorNode) : Node(editorNode)
@@ -61,13 +61,13 @@ void CryptomatteNode::convertToOperations(NodeConverter &converter,
   separateOperation->setChannel(3);
   converter.addOperation(separateOperation);
 
-  SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+  SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation();
   converter.addOperation(operationAlpha);
 
   converter.addLink(operation->getOutputSocket(0), separateOperation->getInputSocket(0));
   converter.addLink(separateOperation->getOutputSocket(0), operationAlpha->getInputSocket(1));
 
-  SetAlphaOperation *clearAlphaOperation = new SetAlphaOperation();
+  SetAlphaMultiplyOperation *clearAlphaOperation = new SetAlphaMultiplyOperation();
   converter.addOperation(clearAlphaOperation);
   converter.addInputValue(clearAlphaOperation->getInputSocket(1), 1.0f);
 
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
index b579502e068..3d538e9b4a0 100644
--- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
@@ -19,7 +19,7 @@
 #include "COM_DifferenceMatteNode.h"
 #include "BKE_node.h"
 #include "COM_DifferenceMatteOperation.h"
-#include "COM_SetAlphaOperation.h"
+#include "COM_SetAlphaMultiplyOperation.h"
 
 DifferenceMatteNode::DifferenceMatteNode(bNode *editorNode) : Node(editorNode)
 {
@@ -43,7 +43,7 @@ void DifferenceMatteNode::convertToOperations(NodeConverter &converter,
   converter.mapInputSocket(inputSocket2, operationSet->getInputSocket(1));
   converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0));
 
-  SetAlphaOperation *operation = new SetAlphaOperation();
+  SetAlphaMultiplyOperation *operation = new SetAlphaMultiplyOperation();
   converter.addOperation(operation);
 
   converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
index 946d55d33fc..37aeb5c8504 100644
--- a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
@@ -21,7 +21,7 @@
 #include "COM_ConvertOperation.h"
 #include "COM_DistanceRGBMatteOperation.h"
 #include "COM_DistanceYCCMatteOperation.h"
-#include "COM_SetAlphaOperation.h"
+#include "COM_SetAlphaMultiplyOperation.h"
 
 DistanceMatteNode::DistanceMatteNode(bNode *editorNode) : Node(editorNode)
 {
@@ -39,7 +39,7 @@ void DistanceMatteNode::convertToOperations(NodeConverter &converter,
   NodeOutput *outputSocketImage = this->getOutputSocket(0);
   NodeOutput *outputSocketMatte = this->getOutputSocket(1);
 
-  SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+  SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation();
   converter.addOperation(operationAlpha);
 
   /* work in RGB color space */
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp
index 9f0cdcbd552..4e81a412c29 100644
--- a/source/blender/compositor/nodes/COM_KeyingNode.cpp
+++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp
@@ -32,7 +32,7 @@
 
 #include "COM_DilateErodeOperation.h"
 
-#include "COM_KeyingSetAlphaOperation.h"
+#include "COM_SetAlphaMultiplyOperation.h"
 
 #include "COM_GaussianAlphaXBlurOperation.h"
 #include "COM_GaussianAlphaYBlurOperation.h"
@@ -323,7 +323,7 @@ void KeyingNode::convertToOperations(NodeConverter &converter,
   }
 
   /* set alpha channel to output image */
-  KeyingSetAlphaOperation *alphaOperation = new KeyingSetAlphaOperation();
+  SetAlphaMultiplyOperation *alphaOperation = new SetAlphaMultiplyOperation();
   converter.addOperation(alphaOperation);
 
   converter.mapInputSocket(inputImage, alphaOperation->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
index e435cefeefe..8bfea1eff49 100644
--- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
@@ -20,7 +20,7 @@
 #include "BKE_node.h"
 #include "COM_ConvertOperation.h"
 #include "COM_LuminanceMatteOperation.h"
-#include "COM_SetAlphaOperation.h"
+#include "COM_SetAlphaMultiplyOperation.h"
 
 LuminanceMatteNode::LuminanceMatteNode(bNode *editorNode) : Node(editorNode)
 {
@@ -42,

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list