[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44297] branches/tile/source/blender/ compositor: TileBranch

Jeroen Bakker j.bakker at atmind.nl
Tue Feb 21 14:13:14 CET 2012


Revision: 44297
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44297
Author:   jbakker
Date:     2012-02-21 13:13:14 +0000 (Tue, 21 Feb 2012)
Log Message:
-----------
TileBranch
 * added color spill node.
 * did some optimizations to the color spill logic

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_ColorSpillNode.cpp
    branches/tile/source/blender/compositor/nodes/COM_ColorSpillNode.h
    branches/tile/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_ColorSpillOperation.h

Modified: branches/tile/source/blender/compositor/CMakeLists.txt
===================================================================
--- branches/tile/source/blender/compositor/CMakeLists.txt	2012-02-21 13:00:58 UTC (rev 44296)
+++ branches/tile/source/blender/compositor/CMakeLists.txt	2012-02-21 13:13:14 UTC (rev 44297)
@@ -286,7 +286,11 @@
 nodes/COM_BoxMaskNode.h
 nodes/COM_EllipseMaskNode.cpp
 nodes/COM_EllipseMaskNode.h
+nodes/COM_ColorSpillNode.cpp
+nodes/COM_ColorSpillNode.h
 
+operations/COM_ColorSpillOperation.cpp
+operations/COM_ColorSpillOperation.h
 		operations/COM_RenderLayersBaseProg.cpp
 		operations/COM_RenderLayersBaseProg.h
 		operations/COM_RenderLayersImageProg.cpp

Modified: branches/tile/source/blender/compositor/intern/COM_Converter.cpp
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-02-21 13:00:58 UTC (rev 44296)
+++ branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-02-21 13:13:14 UTC (rev 44297)
@@ -102,6 +102,7 @@
 #include "COM_OpenCLTestNode.h"
 #include "COM_GlareNode.h"
 #include "COM_MovieClipNode.h"
+#include "COM_ColorSpillNode.h"
 
 Node* Converter::convert(bNode *bNode) {
 	Node * node;
@@ -308,11 +309,13 @@
 	case CMP_NODE_MOVIECLIP:
 		node = new MovieClipNode(bNode);
 		break;
+	case CMP_NODE_COLOR_SPILL:
+		node = new ColorSpillNode(bNode);
+		break;
 	/* not inplemented yet */
 	case CMP_NODE_MAP_VALUE:
 	case CMP_NODE_VECBLUR:
 	case CMP_NODE_OUTPUT_FILE:
-	case CMP_NODE_COLOR_SPILL:
 	case CMP_NODE_DOUBLEEDGEMASK:
 	case CMP_NODE_DEFOCUS:
 	case CMP_NODE_CROP:

Added: branches/tile/source/blender/compositor/nodes/COM_ColorSpillNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_ColorSpillNode.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_ColorSpillNode.cpp	2012-02-21 13:13:14 UTC (rev 44297)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2011, 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
+ */
+
+#include "COM_ColorSpillNode.h"
+#include "BKE_node.h"
+#include "COM_ColorSpillOperation.h"
+
+ColorSpillNode::ColorSpillNode(bNode *editorNode): Node(editorNode)
+{}
+
+void ColorSpillNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) {
+	InputSocket *inputSocketImage = this->getInputSocket(0);
+	InputSocket *inputSocketFac = this->getInputSocket(1);
+	OutputSocket *outputSocketImage = this->getOutputSocket(0);
+
+	bNode* editorsnode = getbNode();
+
+	
+	ColorSpillOperation *operation;
+	if (editorsnode->custom2 == 0) {
+		// Simple color spill
+		operation = new ColorSpillOperation();
+	} else {
+		// Average color spill
+		operation = new ColorSpillAverageOperation();
+	}
+	operation->setSettings((NodeColorspill*)editorsnode->storage);
+	operation->setSpillChannel(editorsnode->custom1-1); // Channel for spilling
+	
+
+	inputSocketImage->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+	inputSocketFac->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+	
+	outputSocketImage->relinkConnections(operation->getOutputSocket());
+	graph->addOperation(operation);
+}

Added: branches/tile/source/blender/compositor/nodes/COM_ColorSpillNode.h
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_ColorSpillNode.h	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_ColorSpillNode.h	2012-02-21 13:13:14 UTC (rev 44297)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, 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
+ */
+
+#ifndef COM_ColorSpillNODE_H
+#define COM_ColorSpillNODE_H
+
+#include "COM_Node.h"
+
+/**
+  * @brief ColorSpillNode
+  * @ingroup Node
+  */
+class ColorSpillNode : public Node
+{
+public:
+	ColorSpillNode(bNode *editorNode);
+	void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif // COM_ColorSpillNODE_H

Added: branches/tile/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_ColorSpillOperation.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_ColorSpillOperation.cpp	2012-02-21 13:13:14 UTC (rev 44297)
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This Reader 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 Reader 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 Reader; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ *		Jeroen Bakker
+ *		Monique Dewanchand
+ */
+
+#include "COM_ColorSpillOperation.h"
+#include "BLI_math.h"
+#define avg(a,b) ((a+b)/2)
+
+ColorSpillOperation::ColorSpillOperation(): NodeOperation() {
+	addInputSocket(COM_DT_COLOR);
+	addInputSocket(COM_DT_VALUE);
+	addOutputSocket(COM_DT_COLOR);
+
+	inputImageReader = NULL;
+	inputFacReader = NULL;
+	this->spillChannel = 1; // GREEN
+}
+
+void ColorSpillOperation::initExecution() {
+	this->inputImageReader = this->getInputSocketReader(0);
+	this->inputFacReader = this->getInputSocketReader(1);
+	if (spillChannel == 0) {
+		rmut = -1.0f;
+		gmut = 1.0f;
+		bmut = 1.0f;
+		this->channel2 = 1;
+		this->channel3 = 2;
+		if (settings->unspill == 0) {
+			settings->uspillr = 1.0f;
+			settings->uspillg = 0.0f;
+			settings->uspillb = 0.0f;
+		}
+	} else if (spillChannel == 1) {
+		rmut = 1.0f;
+		gmut = -1.0f;
+		bmut = 1.0f;
+		this->channel2 = 0;
+		this->channel3 = 2;
+		if (settings->unspill == 0) {
+			settings->uspillr = 0.0f;
+			settings->uspillg = 1.0f;
+			settings->uspillb = 0.0f;
+		}
+	} else {
+		rmut = 1.0f;
+		gmut = 1.0f;
+		bmut = -1.0f;
+		
+		this->channel2 = 0;
+		this->channel3 = 1;
+		if (settings->unspill == 0) {
+			settings->uspillr = 0.0f;
+			settings->uspillg = 0.0f;
+			settings->uspillb = 1.0f;
+		}
+	}
+}
+
+void ColorSpillOperation::deinitExecution() {
+	this->inputImageReader= NULL;
+	this->inputFacReader = NULL;
+}
+
+void ColorSpillOperation::executePixel(float* outputValue, float x, float y, MemoryBuffer *inputBuffers[]) {
+	float fac[4];
+	float input[4];
+	float map;	
+	this->inputFacReader->read(fac, x, y, inputBuffers);
+	this->inputImageReader->read(input, x, y, inputBuffers);
+	float rfac = min(1.0f, fac[0]);
+	map = calculateMapValue(rfac, input);
+	if(map>0) {
+		outputValue[0]=input[0]+rmut*(settings->uspillr*map);
+		outputValue[1]=input[1]+gmut*(settings->uspillg*map);
+		outputValue[2]=input[2]+bmut*(settings->uspillb*map);
+		outputValue[3]=input[3];
+	}
+	else {
+		outputValue[0]=input[0];
+		outputValue[1]=input[1];
+		outputValue[2]=input[2];
+		outputValue[3]=input[3];
+	}	
+}
+float ColorSpillOperation::calculateMapValue(float fac, float *input) {
+	return fac * (input[this->spillChannel]-(this->settings->limscale*input[settings->limchan]));
+}
+
+
+float ColorSpillAverageOperation::calculateMapValue(float fac, float *input) {
+	return fac * (input[this->spillChannel]-(this->settings->limscale*avg(input[this->channel2], input[this->channel3])));
+}

Added: branches/tile/source/blender/compositor/operations/COM_ColorSpillOperation.h
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_ColorSpillOperation.h	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_ColorSpillOperation.h	2012-02-21 13:13:14 UTC (rev 44297)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011, 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
+ */
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list