[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43973] branches/tile/source/blender/ compositor: Channel Matte Node Tile

Dalai Felinto dfelinto at gmail.com
Tue Feb 7 23:20:20 CET 2012


Revision: 43973
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43973
Author:   dfelinto
Date:     2012-02-07 22:20:10 +0000 (Tue, 07 Feb 2012)
Log Message:
-----------
Channel Matte Node Tile
node from trunk converted to tile.

Modified Paths:
--------------
    branches/tile/source/blender/compositor/CMakeLists.txt
    branches/tile/source/blender/compositor/intern/COM_Converter.cpp

Added Paths:
-----------
    branches/tile/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
    branches/tile/source/blender/compositor/nodes/COM_ChannelMatteNode.h
    branches/tile/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_ChannelMatteOperation.h

Modified: branches/tile/source/blender/compositor/CMakeLists.txt
===================================================================
--- branches/tile/source/blender/compositor/CMakeLists.txt	2012-02-07 21:04:10 UTC (rev 43972)
+++ branches/tile/source/blender/compositor/CMakeLists.txt	2012-02-07 22:20:10 UTC (rev 43973)
@@ -165,6 +165,8 @@
 		nodes/COM_ChromaMatteNode.h
 		nodes/COM_ColorMatteNode.cpp
 		nodes/COM_ColorMatteNode.h
+		nodes/COM_ChannelMatteNode.cpp
+		nodes/COM_ChannelMatteNode.h
 		nodes/COM_LensDistortionNode.cpp
 		nodes/COM_LensDistortionNode.h
 
@@ -400,6 +402,8 @@
 	operations/COM_ChromaMatteOperation.h
 	operations/COM_ColorMatteOperation.cpp
 	operations/COM_ColorMatteOperation.h
+	operations/COM_ChannelMatteOperation.cpp
+	operations/COM_ChannelMatteOperation.h
 
 	operations/COM_ReadBufferOperation.cpp
 	operations/COM_ReadBufferOperation.h

Modified: branches/tile/source/blender/compositor/intern/COM_Converter.cpp
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-02-07 21:04:10 UTC (rev 43972)
+++ branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-02-07 22:20:10 UTC (rev 43973)
@@ -80,6 +80,7 @@
 #include "COM_DistanceMatteNode.h"
 #include "COM_ChromaMatteNode.h"
 #include "COM_ColorMatteNode.h"
+#include "COM_ChannelMatteNode.h"
 #include "COM_BlurNode.h"
 #include "COM_BokehBlurNode.h"
 #include "COM_DilateErodeNode.h"
@@ -254,6 +255,9 @@
 	case CMP_NODE_COLOR_MATTE:
 		node = new ColorMatteNode(bNode);
 		break;
+	case CMP_NODE_CHANNEL_MATTE:
+		node = new ChannelMatteNode(bNode);
+		break;
 	case CMP_NODE_BLUR:
 		node = new BlurNode(bNode);
 		break;
@@ -305,7 +309,6 @@
 	case CMP_NODE_VECBLUR:
 	case CMP_NODE_OUTPUT_FILE:
 	case CMP_NODE_COLOR_SPILL:
-	case CMP_NODE_CHANNEL_MATTE:
 	case CMP_NODE_DOUBLEEDGEMASK:
 	case CMP_NODE_DEFOCUS:
 	case CMP_NODE_CROP:

Added: branches/tile/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp	2012-02-07 22:20:10 UTC (rev 43973)
@@ -0,0 +1,89 @@
+/*
+ * 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:
+ *		Dalai Felinto
+ */
+
+#include "COM_ChannelMatteNode.h"
+#include "BKE_node.h"
+#include "COM_ChannelMatteOperation.h"
+#include "COM_ConvertRGBToHSVOperation.h"
+#include "COM_ConvertRGBToYCCOperation.h"
+#include "COM_ConvertRGBToYUVOperation.h"
+#include "COM_SetAlphaOperation.h"
+
+ChannelMatteNode::ChannelMatteNode(bNode *editorNode): Node(editorNode)
+{}
+
+void ChannelMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) {
+	InputSocket *inputSocketImage = this->getInputSocket(0);
+	OutputSocket *outputSocketImage = this->getOutputSocket(0);
+	OutputSocket *outputSocketMatte = this->getOutputSocket(1);
+
+	NodeOperation *convert=NULL;
+	bNode* node = this->getbNode();
+
+	/* colorspace */
+	switch(node->custom1) {
+	case CMP_NODE_CHANNEL_MATTE_CS_RGB:
+		break;
+	case CMP_NODE_CHANNEL_MATTE_CS_HSV: /*HSV*/
+		convert = new ConvertRGBToHSVOperation();
+		break;
+	case CMP_NODE_CHANNEL_MATTE_CS_YUV: /*YUV*/
+		convert = new ConvertRGBToYUVOperation();
+		break;
+	case CMP_NODE_CHANNEL_MATTE_CS_YCC: /*YCC*/
+		convert = new ConvertRGBToYCCOperation();
+		((ConvertRGBToYCCOperation *)convert)->setMode(0); /* BLI_YCC_ITU_BT601 */
+		break;
+	default:
+		break;
+	}
+
+	ChannelMatteOperation *operation = new ChannelMatteOperation();
+	/* pass the ui properties to the operation */
+	operation->setSettings((NodeChroma*)node->storage, node->custom2);
+
+	SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+
+	if (convert) {
+		inputSocketImage->relinkConnections(convert->getInputSocket(0), true, 0, graph);
+		addLink(graph, convert->getOutputSocket(), operation->getInputSocket(0));
+		addLink(graph, convert->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0));
+		graph->addOperation(convert);
+	}
+	else {
+		inputSocketImage->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+		addLink(graph, operation->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0));
+	}
+
+	if (outputSocketMatte->isConnected()) {
+		outputSocketMatte->relinkConnections(operation->getOutputSocket(0));
+	}
+
+	graph->addOperation(operation);
+	graph->addOperation(operationAlpha);
+
+	addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1));
+	addPreviewOperation(graph, operationAlpha->getOutputSocket(), 9);
+
+	if (outputSocketImage->isConnected()) {
+		outputSocketImage->relinkConnections(operationAlpha->getOutputSocket());
+	}
+}


Property changes on: branches/tile/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
___________________________________________________________________
Added: svn:eol
   + native

Added: branches/tile/source/blender/compositor/nodes/COM_ChannelMatteNode.h
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_ChannelMatteNode.h	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_ChannelMatteNode.h	2012-02-07 22:20:10 UTC (rev 43973)
@@ -0,0 +1,38 @@
+/*
+ * 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:
+ *		Dalai Felinto
+ */
+
+#ifndef COM_ChannelMatteNODE_H
+#define COM_ChannelMatteNODE_H
+
+#include "COM_Node.h"
+
+/**
+  * @brief ChannelMatteNode
+  * @ingroup Node
+  */
+class ChannelMatteNode : public Node
+{
+public:
+	ChannelMatteNode(bNode *editorNode);
+	void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif // COM_ChannelMatteNODE_H


Property changes on: branches/tile/source/blender/compositor/nodes/COM_ChannelMatteNode.h
___________________________________________________________________
Added: svn:eol
   + native

Added: branches/tile/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp	2012-02-07 22:20:10 UTC (rev 43973)
@@ -0,0 +1,117 @@
+/*
+ * 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:
+ *		Dalai Felinto
+ */
+
+#include "COM_ChannelMatteOperation.h"
+#include "BLI_math.h"
+
+ChannelMatteOperation::ChannelMatteOperation(): NodeOperation() {
+	addInputSocket(COM_DT_COLOR);
+	addOutputSocket(COM_DT_VALUE);
+
+	inputImageProgram = NULL;
+}
+
+void ChannelMatteOperation::initExecution() {
+	this->inputImageProgram = this->getInputSocketReader(0);
+
+	this->limit_range = this->limit_max - this->limit_min;
+
+	switch (this->limit_method) {
+		/* SINGLE */
+		case 0: {
+		/* 123 / RGB / HSV / YUV / YCC */
+			const int matte_channel=this->matte_channel-1;
+			const int limit_channel=this->limit_channel-1;
+			this->ids[0] = matte_channel;
+			this->ids[1] = limit_channel;
+			this->ids[2] = limit_channel;
+			break;
+		}
+		/* MAX */
+		case 1: {
+			switch (this->matte_channel) {
+				case 1: {
+					this->ids[0] = 0;
+					this->ids[1] = 1;
+					this->ids[2] = 2;
+					break;
+				}
+				case 2: {
+					this->ids[0] = 1;
+					this->ids[1] = 0;
+					this->ids[2] = 2;
+					break;
+				}
+				case 3: {
+					this->ids[0] = 2;
+					this->ids[1] = 0;
+					this->ids[2] = 1;
+					break;
+				}
+				default:
+					break;
+			}
+			break;
+		}
+		default:
+			break;
+	}
+}
+
+void ChannelMatteOperation::deinitExecution() {
+	this->inputImageProgram= NULL;
+}
+
+void ChannelMatteOperation::executePixel(float* outputValue, float x, float y, MemoryBuffer *inputBuffers[]) {
+	float inColor[4];
+	float alpha;
+
+	const float limit_max = this->limit_max;
+	const float limit_min = this->limit_min;
+	const float limit_range = this->limit_range;
+
+	this->inputImageProgram->read(inColor, x, y, inputBuffers);
+
+	/* matte operation */
+	alpha = inColor[this->ids[0]] - max(inColor[this->ids[1]], inColor[this->ids[2]]);
+		

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list