[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47894] trunk/blender/source/blender: Kaying node from tomato branch

Sergey Sharybin sergey.vfx at gmail.com
Thu Jun 14 14:19:14 CEST 2012


Revision: 47894
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47894
Author:   nazgul
Date:     2012-06-14 12:19:13 +0000 (Thu, 14 Jun 2012)
Log Message:
-----------
Kaying node from tomato branch

Merge keying node from tomato branch into trunk.

It was considered stable and helpful by Mango team and it'll help
studio pipeline, because nodes would stop disappearing when opening
files in current trunk.

Full information about keying nodes could be found there:
http://wiki.blender.org/index.php/User:Nazg-gul/Keying

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_node.h
    trunk/blender/source/blender/blenkernel/intern/node.c
    trunk/blender/source/blender/compositor/CMakeLists.txt
    trunk/blender/source/blender/compositor/intern/COM_Converter.cpp
    trunk/blender/source/blender/editors/space_clip/clip_dopesheet_ops.c
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/makesdna/DNA_node_types.h
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
    trunk/blender/source/blender/makesrna/intern/rna_nodetree_types.h
    trunk/blender/source/blender/nodes/CMakeLists.txt
    trunk/blender/source/blender/nodes/NOD_composite.h

Added Paths:
-----------
    trunk/blender/source/blender/compositor/nodes/COM_KeyingNode.cpp
    trunk/blender/source/blender/compositor/nodes/COM_KeyingNode.h
    trunk/blender/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_KeyingBlurOperation.h
    trunk/blender/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_KeyingClipOperation.h
    trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_KeyingDespillOperation.h
    trunk/blender/source/blender/compositor/operations/COM_KeyingOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_KeyingOperation.h
    trunk/blender/source/blender/nodes/composite/nodes/node_composite_keying.c

Modified: trunk/blender/source/blender/blenkernel/BKE_node.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_node.h	2012-06-14 12:18:42 UTC (rev 47893)
+++ trunk/blender/source/blender/blenkernel/BKE_node.h	2012-06-14 12:19:13 UTC (rev 47894)
@@ -659,6 +659,7 @@
 #define CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED	267	/* DEPRECATED multi file node has been merged into regular CMP_NODE_OUTPUT_FILE */
 #define CMP_NODE_MASK		268
 #define CMP_NODE_KEYINGSCREEN		269
+#define CMP_NODE_KEYING			270
 
 #define CMP_NODE_GLARE		301
 #define CMP_NODE_TONEMAP	302

Modified: trunk/blender/source/blender/blenkernel/intern/node.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/node.c	2012-06-14 12:18:42 UTC (rev 47893)
+++ trunk/blender/source/blender/blenkernel/intern/node.c	2012-06-14 12:19:13 UTC (rev 47894)
@@ -1901,6 +1901,7 @@
 	register_node_type_cmp_luma_matte(ttype);
 	register_node_type_cmp_doubleedgemask(ttype);
 	register_node_type_cmp_keyingscreen(ttype);
+	register_node_type_cmp_keying(ttype);
 
 	register_node_type_cmp_translate(ttype);
 	register_node_type_cmp_rotate(ttype);

Modified: trunk/blender/source/blender/compositor/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/compositor/CMakeLists.txt	2012-06-14 12:18:42 UTC (rev 47893)
+++ trunk/blender/source/blender/compositor/CMakeLists.txt	2012-06-14 12:19:13 UTC (rev 47894)
@@ -330,6 +330,17 @@
 	operations/COM_KeyingScreenOperation.cpp
 	operations/COM_KeyingScreenOperation.h
 
+	nodes/COM_KeyingNode.cpp
+	nodes/COM_KeyingNode.h
+	operations/COM_KeyingOperation.cpp
+	operations/COM_KeyingOperation.h
+	operations/COM_KeyingBlurOperation.cpp
+	operations/COM_KeyingBlurOperation.h
+	operations/COM_KeyingDespillOperation.cpp
+	operations/COM_KeyingDespillOperation.h
+	operations/COM_KeyingClipOperation.cpp
+	operations/COM_KeyingClipOperation.h
+
 	operations/COM_ColorSpillOperation.cpp
 	operations/COM_ColorSpillOperation.h
 	operations/COM_RenderLayersBaseProg.cpp

Modified: trunk/blender/source/blender/compositor/intern/COM_Converter.cpp
===================================================================
--- trunk/blender/source/blender/compositor/intern/COM_Converter.cpp	2012-06-14 12:18:42 UTC (rev 47893)
+++ trunk/blender/source/blender/compositor/intern/COM_Converter.cpp	2012-06-14 12:19:13 UTC (rev 47894)
@@ -113,6 +113,7 @@
 #include "COM_CropNode.h"
 #include "COM_MaskNode.h"
 #include "COM_KeyingScreenNode.h"
+#include "COM_KeyingNode.h"
 
 Node *Converter::convert(bNode *bNode)
 {
@@ -355,6 +356,9 @@
 	case CMP_NODE_KEYINGSCREEN:
 		node = new KeyingScreenNode(bNode);
 		break;
+	case CMP_NODE_KEYING:
+		node = new KeyingNode(bNode);
+		break;
 	/* not inplemented yet */
 	default:
 		node = new MuteNode(bNode);

Added: trunk/blender/source/blender/compositor/nodes/COM_KeyingNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_KeyingNode.cpp	                        (rev 0)
+++ trunk/blender/source/blender/compositor/nodes/COM_KeyingNode.cpp	2012-06-14 12:19:13 UTC (rev 47894)
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ *		Jeroen Bakker
+ *		Monique Dewanchand
+ *		Sergey Sharybin
+ */
+
+#include "COM_KeyingNode.h"
+
+#include "COM_ExecutionSystem.h"
+
+#include "COM_KeyingOperation.h"
+#include "COM_KeyingBlurOperation.h"
+#include "COM_KeyingDespillOperation.h"
+#include "COM_KeyingClipOperation.h"
+
+#include "COM_SeparateChannelOperation.h"
+#include "COM_CombineChannelsOperation.h"
+#include "COM_ConvertRGBToYCCOperation.h"
+#include "COM_ConvertYCCToRGBOperation.h"
+#include "COM_GaussianBokehBlurOperation.h"
+#include "COM_SetValueOperation.h"
+
+#include "COM_DilateErodeOperation.h"
+
+#include "COM_SetAlphaOperation.h"
+
+KeyingNode::KeyingNode(bNode *editorNode): Node(editorNode)
+{
+}
+
+OutputSocket *KeyingNode::setupPreBlur(ExecutionSystem *graph, InputSocket *inputImage, int size, OutputSocket **originalImage)
+{
+	ConvertRGBToYCCOperation *convertRGBToYCCOperation = new ConvertRGBToYCCOperation();
+	convertRGBToYCCOperation->setMode(0);  /* ITU 601 */
+
+	inputImage->relinkConnections(convertRGBToYCCOperation->getInputSocket(0), 0, graph);
+	graph->addOperation(convertRGBToYCCOperation);
+
+	CombineChannelsOperation *combineOperation = new CombineChannelsOperation();
+	graph->addOperation(combineOperation);
+
+	for (int channel = 0; channel < 4; channel++) {
+		SeparateChannelOperation *separateOperation = new SeparateChannelOperation();
+		separateOperation->setChannel(channel);
+		addLink(graph, convertRGBToYCCOperation->getOutputSocket(0), separateOperation->getInputSocket(0));
+		graph->addOperation(separateOperation);
+
+		if (channel == 0 || channel == 3) {
+			addLink(graph, separateOperation->getOutputSocket(0), combineOperation->getInputSocket(channel));
+		}
+		else {
+			KeyingBlurOperation *blurOperation = new KeyingBlurOperation();
+
+			blurOperation->setSize(size);
+
+			addLink(graph, separateOperation->getOutputSocket(0), blurOperation->getInputSocket(0));
+			addLink(graph, blurOperation->getOutputSocket(0), combineOperation->getInputSocket(channel));
+			graph->addOperation(blurOperation);
+		}
+	}
+
+	ConvertYCCToRGBOperation *convertYCCToRGBOperation = new ConvertYCCToRGBOperation();
+	convertYCCToRGBOperation->setMode(0);  /* ITU 601 */
+	addLink(graph, combineOperation->getOutputSocket(0), convertYCCToRGBOperation->getInputSocket(0));
+	graph->addOperation(convertYCCToRGBOperation);
+
+	*originalImage = convertRGBToYCCOperation->getInputSocket(0)->getConnection()->getFromSocket();
+
+	return convertYCCToRGBOperation->getOutputSocket(0);
+}
+
+OutputSocket *KeyingNode::setupPostBlur(ExecutionSystem *graph, OutputSocket *postBLurInput, int size)
+{
+	KeyingBlurOperation *blurOperation = new KeyingBlurOperation();
+
+	blurOperation->setSize(size);
+
+	addLink(graph, postBLurInput, blurOperation->getInputSocket(0));
+
+	graph->addOperation(blurOperation);
+
+	return blurOperation->getOutputSocket();
+}
+
+OutputSocket *KeyingNode::setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance)
+{
+	DilateStepOperation *dilateErodeOperation;
+
+	if (distance > 0) {
+		dilateErodeOperation = new DilateStepOperation();
+		dilateErodeOperation->setIterations(distance);
+	}
+	else {
+		dilateErodeOperation = new ErodeStepOperation();
+		dilateErodeOperation->setIterations(-distance);
+	}
+
+	addLink(graph, dilateErodeInput, dilateErodeOperation->getInputSocket(0));
+
+	graph->addOperation(dilateErodeOperation);
+
+	return dilateErodeOperation->getOutputSocket(0);
+}
+
+OutputSocket *KeyingNode::setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputScreen, float factor)
+{
+	KeyingDespillOperation *despillOperation = new KeyingDespillOperation();
+
+	despillOperation->setDespillFactor(factor);
+
+	addLink(graph, despillInput, despillOperation->getInputSocket(0));
+	addLink(graph, inputScreen, despillOperation->getInputSocket(1));
+
+	graph->addOperation(despillOperation);
+
+	return despillOperation->getOutputSocket(0);
+}
+
+OutputSocket *KeyingNode::setupClip(ExecutionSystem *graph, OutputSocket *clipInput, int kernelRadius, float kernelTolerance,
+                                    float clipBlack, float clipWhite, bool edgeMatte)
+{
+	KeyingClipOperation *clipOperation = new KeyingClipOperation();
+
+	clipOperation->setKernelRadius(kernelRadius);
+	clipOperation->setKernelTolerance(kernelTolerance);
+
+	clipOperation->setClipBlack(clipBlack);
+	clipOperation->setClipWhite(clipWhite);
+	clipOperation->setIsEdgeMatte(edgeMatte);
+
+	addLink(graph, clipInput, clipOperation->getInputSocket(0));
+
+	graph->addOperation(clipOperation);
+
+	return clipOperation->getOutputSocket(0);
+}
+
+void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+{
+	InputSocket *inputImage = this->getInputSocket(0);
+	InputSocket *inputScreen = this->getInputSocket(1);
+	OutputSocket *outputImage = this->getOutputSocket(0);
+	OutputSocket *outputMatte = this->getOutputSocket(1);
+	OutputSocket *outputEdges = this->getOutputSocket(2);
+	OutputSocket *postprocessedMatte, *postprocessedImage, *originalImage, *edgesMatte;
+
+	bNode *editorNode = this->getbNode();
+	NodeKeyingData *keying_data = (NodeKeyingData *) editorNode->storage;
+
+	/* keying operation */
+	KeyingOperation *keyingOperation = new KeyingOperation();
+
+	keyingOperation->setScreenBalance(keying_data->screen_balance);
+
+	inputScreen->relinkConnections(keyingOperation->getInputSocket(1), 1, graph);
+
+	if (keying_data->blur_pre) {
+		/* chroma preblur operation for input of keying operation  */
+		OutputSocket *preBluredImage = setupPreBlur(graph, inputImage, keying_data->blur_pre, &originalImage);
+		addLink(graph, preBluredImage, keyingOperation->getInputSocket(0));
+	}
+	else {
+		inputImage->relinkConnections(keyingOperation->getInputSocket(0), 0, graph);
+		originalImage = keyingOperation->getInputSocket(0)->getConnection()->getFromSocket();
+	}
+
+	graph->addOperation(keyingOperation);
+
+	postprocessedMatte = keyingOperation->getOutputSocket();
+
+	if (keying_data->clip_black > 0.0f || keying_data->clip_white< 1.0f) {
+		postprocessedMatte = setupClip(graph, postprocessedMatte,
+		                               keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance,
+		                               keying_data->clip_black, keying_data->clip_white, false);
+	}
+
+	edgesMatte = setupClip(graph, postprocessedMatte,

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list