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

Jeroen Bakker j.bakker at atmind.nl
Tue Apr 10 17:48:28 CEST 2012


Revision: 45513
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45513
Author:   jbakker
Date:     2012-04-10 15:48:28 +0000 (Tue, 10 Apr 2012)
Log Message:
-----------
TileBranch:
 * added a simple implementation of the bilateral blur. The implementation needs still has a lot of places to improve speed. The simplicity of the kernel makes it an ideal candidate for OpenCL!

 - At Mind - 

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_BilateralBlurNode.cpp
    branches/tile/source/blender/compositor/nodes/COM_BilateralBlurNode.h
    branches/tile/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_BilateralBlurOperation.h

Modified: branches/tile/source/blender/compositor/CMakeLists.txt
===================================================================
--- branches/tile/source/blender/compositor/CMakeLists.txt	2012-04-10 15:47:34 UTC (rev 45512)
+++ branches/tile/source/blender/compositor/CMakeLists.txt	2012-04-10 15:48:28 UTC (rev 45513)
@@ -263,6 +263,10 @@
 # Filter nodes
 	nodes/COM_SamplerNode.cpp
 	nodes/COM_SamplerNode.h
+	nodes/COM_BilateralBlurNode.cpp
+	nodes/COM_BilateralBlurNode.h
+	operations/COM_BilateralBlurOperation.cpp
+	operations/COM_BilateralBlurOperation.h
 
 		nodes/COM_FilterNode.cpp
 		nodes/COM_FilterNode.h

Modified: branches/tile/source/blender/compositor/intern/COM_Converter.cpp
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-04-10 15:47:34 UTC (rev 45512)
+++ branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-04-10 15:48:28 UTC (rev 45513)
@@ -108,6 +108,7 @@
 #include "COM_TransformNode.h"
 #include "COM_Stabilize2dNode.h"
 #include "COM_SamplerNode.h"
+#include "COM_BilateralBlurNode.h"
 
 Node* Converter::convert(bNode *bNode) {
 	Node * node;
@@ -332,12 +333,14 @@
 	case CMP_NODE_SAMPLER:
 		node = new SamplerNode(bNode);
 		break;
+	case CMP_NODE_BILATERALBLUR:
+		node = new BilateralBlurNode(bNode);
+		break;
 	/* not inplemented yet */
 	case CMP_NODE_VECBLUR:
 	case CMP_NODE_DOUBLEEDGEMASK:
 	case CMP_NODE_DEFOCUS:
 	case CMP_NODE_CROP:
-	case CMP_NODE_BILATERALBLUR:
 	case CMP_NODE_PREMULKEY:
 	case CMP_NODE_VIEW_LEVELS:
 	case CMP_NODE_MOVIEDISTORTION:

Added: branches/tile/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp	2012-04-10 15:48:28 UTC (rev 45513)
@@ -0,0 +1,41 @@
+/*
+ * 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_BilateralBlurNode.h"
+#include "DNA_scene_types.h"
+#include "DNA_node_types.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_BilateralBlurOperation.h"
+
+BilateralBlurNode::BilateralBlurNode(bNode *editorNode): Node(editorNode) {
+}
+
+void BilateralBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+	NodeBilateralBlurData *data = (NodeBilateralBlurData*)this->getbNode()->storage;
+	BilateralBlurOperation *operation = new BilateralBlurOperation();
+	operation->setQuality(context->getQuality());
+	operation->setData(data);
+	this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+	this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+	this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+	graph->addOperation(operation);
+}

Added: branches/tile/source/blender/compositor/nodes/COM_BilateralBlurNode.h
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_BilateralBlurNode.h	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_BilateralBlurNode.h	2012-04-10 15:48:28 UTC (rev 45513)
@@ -0,0 +1,38 @@
+/*
+ * 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_BilateralBlurNode_h_
+#define _COM_BilateralBlurNode_h_
+
+#include "COM_Node.h"
+
+/**
+  * @brief BilateralBlurNode
+  * @ingroup Node
+  */
+class BilateralBlurNode: public Node {
+public:
+	BilateralBlurNode(bNode *editorNode);
+    void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif

Added: branches/tile/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp	2012-04-10 15:48:28 UTC (rev 45513)
@@ -0,0 +1,109 @@
+/*
+ * 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_BilateralBlurOperation.h"
+#include "BLI_math.h"
+
+extern "C" {
+	#include "RE_pipeline.h"
+}
+
+BilateralBlurOperation::BilateralBlurOperation() : NodeOperation() {
+	this->addInputSocket(COM_DT_COLOR);
+	this->addInputSocket(COM_DT_COLOR);
+	this->addOutputSocket(COM_DT_COLOR);
+	this->setComplex(true);
+
+	this->inputColorProgram = NULL;
+	this->inputDeterminatorProgram = NULL;
+}
+
+void BilateralBlurOperation::initExecution() {
+	this->inputColorProgram = getInputSocketReader(0);
+	this->inputDeterminatorProgram = getInputSocketReader(1);
+	QualityStepHelper::initExecution(COM_QH_INCREASE);
+}
+
+void BilateralBlurOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+	// read the determinator color at x, y, this will be used as the reference color for the determinator
+	float determinatorReferenceColor[4];
+	float determinator[4];
+	float tempColor[4];
+	float blurColor[4];
+	float blurDivider;
+	int minx = x - this->data->sigma_space;
+	int maxx = x + this->data->sigma_space;
+	int miny = y - this->data->sigma_space;
+	int maxy = y + this->data->sigma_space;
+	float deltaColor;
+	this->inputDeterminatorProgram->read(determinatorReferenceColor, x, y, inputBuffers, data);
+	
+	blurColor[0] = 0.0f;
+	blurColor[1] = 0.0f;
+	blurColor[2] = 0.0f;
+	blurDivider = 0.0f;
+	for (int yi = miny ; yi < maxy ; yi++) {
+		for (int xi = minx ; xi < maxx ; xi++) {
+			// read determinator
+			this->inputDeterminatorProgram->read(determinator, xi, yi, inputBuffers, data);
+			deltaColor = fabsf(determinatorReferenceColor[0] - determinator[0])+
+			        fabsf(determinatorReferenceColor[1] - determinator[1])+
+			        fabsf(determinatorReferenceColor[2] - determinator[2]); // do not take the alpha channel into account
+			if (deltaColor< this->data->sigma_color) {
+				// add this to the blur
+				this->inputColorProgram->read(tempColor, xi, yi, inputBuffers, data);
+				blurColor[0]+=tempColor[0];
+				blurColor[1]+=tempColor[1];
+				blurColor[2]+=tempColor[2];
+				blurDivider += 1.0f;
+			}
+		}
+	}
+	
+	if (blurDivider > 0.0f) {
+		color[0] = blurColor[0]/blurDivider;
+		color[1] = blurColor[1]/blurDivider;
+		color[2] = blurColor[2]/blurDivider;
+		color[3] = 1.0f;
+	} else {
+		color[0] = 0.0f;
+		color[1] = 0.0f;
+		color[2] = 0.0f;
+		color[3] = 1.0f;
+	}
+}
+
+void BilateralBlurOperation::deinitExecution() {
+	this->inputColorProgram = NULL;
+	this->inputDeterminatorProgram = NULL;
+}
+
+bool BilateralBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+	rcti newInput;
+
+	newInput.xmax = input->xmax + (this->data->sigma_space);
+	newInput.xmin = input->xmin - (this->data->sigma_space);
+	newInput.ymax = input->ymax + (this->data->sigma_space);
+	newInput.ymin = input->ymin - (this->data->sigma_space);
+
+	return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}

Added: branches/tile/source/blender/compositor/operations/COM_BilateralBlurOperation.h
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_BilateralBlurOperation.h	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_BilateralBlurOperation.h	2012-04-10 15:48:28 UTC (rev 45513)
@@ -0,0 +1,56 @@
+/*
+ * 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

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list