[Bf-blender-cvs] [91b0614b508] temp_cryptomatte: Compositor: fixed crypto matte false color picking, now allows negative numbers and draws nicer false colors

Stefan Werner noreply at git.blender.org
Fri Nov 3 21:09:41 CET 2017


Commit: 91b0614b508eee2facaf1cb70cd2090e221dbffe
Author: Stefan Werner
Date:   Fri Apr 7 10:56:08 2017 +0200
Branches: temp_cryptomatte
https://developer.blender.org/rB91b0614b508eee2facaf1cb70cd2090e221dbffe

Compositor: fixed crypto matte false color picking, now allows negative numbers and draws nicer false colors

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

M	source/blender/compositor/operations/COM_CryptomatteOperation.cpp
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/composite/nodes/node_composite_cryptomatte.c

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

diff --git a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
index cd0b3c953f8..a6521e5bfdb 100644
--- a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
@@ -53,10 +53,10 @@ void CryptomatteOperation::executePixel(float output[4],
 		inputs[i]->read(input, x, y, data);
 		if (i == 0) {
 			// write the frontmost object as false color for picking
-			output[0] = input[0] >= 0.f ? input[0] : 0.f;
-			output[1] = input[0] < 0.f ? -input[0] : 0.f;
+			output[0] = input[0];
 			uint32_t m3hash;
 			::memcpy(&m3hash, &input[0], 4);
+			output[1] = ((float) ((m3hash << 8)) / (float) UINT32_MAX);
 			output[2] = ((float) ((m3hash << 16)) / (float) UINT32_MAX);
 		}
 		for(float f : m_objectIndex) {
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index bc7a365558e..55f16dc1cb4 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -6818,6 +6818,7 @@ static void def_cmp_cryptomatte(StructRNA *srna)
 	RNA_def_property_float_sdna(prop, NULL, "add");
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_float_array_default(prop, default_1);
+	RNA_def_property_range(prop,  -FLT_MAX, FLT_MAX);
 	RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
 	RNA_def_property_ui_text(prop, "Add", "Add to matte");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeCryptomatte_update_add");
@@ -6826,6 +6827,7 @@ static void def_cmp_cryptomatte(StructRNA *srna)
 	RNA_def_property_float_sdna(prop, NULL, "remove");
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_float_array_default(prop, default_1);
+	RNA_def_property_range(prop,  -FLT_MAX, FLT_MAX);
 	RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
 	RNA_def_property_ui_text(prop, "Remove", "Remove from matte");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeCryptomatte_update_remove");
diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
index 526688b2cf7..653480cdef3 100644
--- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
@@ -52,20 +52,22 @@ static bNodeSocketTemplate outputs[] = {
 void ntreeCompositCryptomatteSyncFromAdd(bNodeTree *UNUSED(ntree), bNode *node)
 {
 	NodeCryptomatte *n = node->storage;
-	if(n->add[0] != 0.f || n->add[1] != 0.f) {
-		cryptomatte_add(n, n->add[0] > n->add[1] ? n->add[0] : -n->add[1]);
+	if(n->add[0] != 0.f) {
+		cryptomatte_add(n, n->add[0]);
 		n->add[0] = 0.f;
 		n->add[1] = 0.f;
+		n->add[2] = 0.f;
 	}
 }
 
 void ntreeCompositCryptomatteSyncFromRemove(bNodeTree *UNUSED(ntree), bNode *node)
 {
 	NodeCryptomatte *n = node->storage;
-	if(n->remove[0] != 0.f || n->remove[1] != 0.f) {
-		cryptomatte_remove(n, n->remove[0] > n->remove[1] ? n->remove[0] : -n->remove[1]);
+	if(n->remove[0] != 0.f) {
+		cryptomatte_remove(n, n->remove[0]);
 		n->remove[0] = 0.f;
 		n->remove[1] = 0.f;
+		n->remove[2] = 0.f;
 	}
 }



More information about the Bf-blender-cvs mailing list