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

Jeroen Bakker j.bakker at atmind.nl
Tue Apr 10 22:14:48 CEST 2012


Revision: 45523
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45523
Author:   jbakker
Date:     2012-04-10 20:14:48 +0000 (Tue, 10 Apr 2012)
Log Message:
-----------
TileBranch
 * added first implementation of the VectorBlur; It uses Blender Internal renderer to calculate the vectorBlur. 
 * still needs some work (artifacts + quality setting)

 - At Mind - 

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

Added Paths:
-----------
    branches/tile/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
    branches/tile/source/blender/compositor/nodes/COM_VectorBlurNode.h
    branches/tile/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_VectorBlurOperation.h

Modified: branches/tile/source/blender/compositor/CMakeLists.txt
===================================================================
--- branches/tile/source/blender/compositor/CMakeLists.txt	2012-04-10 19:27:02 UTC (rev 45522)
+++ branches/tile/source/blender/compositor/CMakeLists.txt	2012-04-10 20:14:48 UTC (rev 45523)
@@ -267,7 +267,13 @@
 	nodes/COM_BilateralBlurNode.h
 	operations/COM_BilateralBlurOperation.cpp
 	operations/COM_BilateralBlurOperation.h
+	nodes/COM_VectorBlurNode.cpp
+	nodes/COM_VectorBlurNode.h
+	operations/COM_VectorBlurOperation.cpp
+	operations/COM_VectorBlurOperation.h
 
+
+
 		nodes/COM_FilterNode.cpp
 		nodes/COM_FilterNode.h
 		nodes/COM_DilateErode2Node.cpp

Modified: branches/tile/source/blender/compositor/intern/COM_Converter.cpp
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-04-10 19:27:02 UTC (rev 45522)
+++ branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-04-10 20:14:48 UTC (rev 45523)
@@ -109,6 +109,7 @@
 #include "COM_Stabilize2dNode.h"
 #include "COM_SamplerNode.h"
 #include "COM_BilateralBlurNode.h"
+#include "COM_VectorBlurNode.h"
 
 Node* Converter::convert(bNode *bNode) {
 	Node * node;
@@ -336,8 +337,10 @@
 	case CMP_NODE_BILATERALBLUR:
 		node = new BilateralBlurNode(bNode);
 		break;
+	case CMP_NODE_VECBLUR:
+		node = new VectorBlurNode(bNode);
+		break;
 	/* not inplemented yet */
-	case CMP_NODE_VECBLUR:
 	case CMP_NODE_DOUBLEEDGEMASK:
 	case CMP_NODE_DEFOCUS:
 	case CMP_NODE_CROP:
@@ -375,6 +378,8 @@
 		inputSocket->relinkConnections(converter->getInputSocket(0));
 		ExecutionSystemHelper::addLink(system->getConnections(), converter->getOutputSocket(), inputSocket);
 		system->addOperation(converter);
+//		converter->getInputSocket(0)->setActualDataType(fromDatatype);
+//		converter->getOutputSocket(1)->setActualDataType(toDatatype);
 	}
 }
 

Modified: branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.cpp
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.cpp	2012-04-10 19:27:02 UTC (rev 45522)
+++ branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.cpp	2012-04-10 20:14:48 UTC (rev 45523)
@@ -65,6 +65,18 @@
 	memset(this->buffer, 0, this->determineBufferSize()*4*sizeof(float));
 }
 
+float* MemoryBuffer::convertToValueBuffer() {
+	int size = this->determineBufferSize();
+	int i;
+	int offset4;
+	float* result = new float[size];
+	for (i = 0, offset4 = 0 ; i < size ; i ++, offset4 +=4) {
+		result[i] = this->buffer[offset4];
+	}
+
+	return result;
+}
+
 MemoryBuffer::~MemoryBuffer() {
 	if (this->buffer) {
 		MEM_freeN(this->buffer);

Modified: branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.h
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.h	2012-04-10 19:27:02 UTC (rev 45522)
+++ branches/tile/source/blender/compositor/intern/COM_MemoryBuffer.h	2012-04-10 20:14:48 UTC (rev 45523)
@@ -161,6 +161,8 @@
 	void clear();
 	
 	MemoryBuffer* duplicate();
+	
+	float* convertToValueBuffer();
 private:
     unsigned int determineBufferSize();
 };

Added: branches/tile/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_VectorBlurNode.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_VectorBlurNode.cpp	2012-04-10 20:14:48 UTC (rev 45523)
@@ -0,0 +1,44 @@
+/*
+ * 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_VectorBlurNode.h"
+#include "DNA_node_types.h"
+#include "COM_FogGlowImageOperation.h"
+#include "COM_BokehBlurOperation.h"
+#include "COM_VectorBlurOperation.h"
+#include "COM_SetValueOperation.h"
+#include "COM_MixBlendOperation.h"
+
+VectorBlurNode::VectorBlurNode(bNode *editorNode): Node(editorNode) {
+}
+
+void VectorBlurNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) {
+	bNode* node = this->getbNode();
+	NodeBlurData* vectorBlurSettings = (NodeBlurData*)node->storage;
+	VectorBlurOperation *operation = new VectorBlurOperation();
+	operation->setVectorBlurSettings(vectorBlurSettings);
+	this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system);
+	this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, system);
+	this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), true, 2, system);
+	this->getOutputSocket()->relinkConnections(operation->getOutputSocket());
+	system->addOperation(operation);
+}

Added: branches/tile/source/blender/compositor/nodes/COM_VectorBlurNode.h
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_VectorBlurNode.h	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_VectorBlurNode.h	2012-04-10 20:14:48 UTC (rev 45523)
@@ -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_VectorBlurNode_h_
+#define _COM_VectorBlurNode_h_
+
+#include "COM_Node.h"
+
+/**
+  * @brief VectorBlurNode
+  * @ingroup Node
+  */
+class VectorBlurNode: public Node {
+public:
+	VectorBlurNode(bNode *editorNode);
+    void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif

Modified: branches/tile/source/blender/compositor/operations/COM_RenderLayersSpeedOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_RenderLayersSpeedOperation.cpp	2012-04-10 19:27:02 UTC (rev 45522)
+++ branches/tile/source/blender/compositor/operations/COM_RenderLayersSpeedOperation.cpp	2012-04-10 20:14:48 UTC (rev 45523)
@@ -23,5 +23,5 @@
 #include "COM_RenderLayersSpeedOperation.h"
 
 RenderLayersSpeedOperation::RenderLayersSpeedOperation() :RenderLayersBaseProg(SCE_PASS_VECTOR, 4) {
-    this->addOutputSocket(COM_DT_VECTOR);
+	this->addOutputSocket(COM_DT_COLOR);
 }

Added: branches/tile/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_VectorBlurOperation.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_VectorBlurOperation.cpp	2012-04-10 20:14:48 UTC (rev 45523)
@@ -0,0 +1,101 @@
+/*
+ * 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_VectorBlurOperation.h"
+#include "BLI_math.h"
+
+// use the implementation of blender internal renderer to calculate the vector blur.
+extern "C" {
+	#include "RE_pipeline.h"
+}
+
+VectorBlurOperation::VectorBlurOperation(): NodeOperation() {
+	this->addInputSocket(COM_DT_COLOR);
+	this->addInputSocket(COM_DT_VALUE); // ZBUF
+	this->addInputSocket(COM_DT_COLOR); //SPEED
+	this->addOutputSocket(COM_DT_COLOR);
+	this->settings = NULL;
+	this->cachedInstance = NULL;
+	this->inputImageProgram = NULL;
+	this->inputSpeedProgram = NULL;
+	this->inputZProgram = NULL;
+	setComplex(true);
+}
+void VectorBlurOperation::initExecution() {
+	initMutex();
+	this->inputImageProgram = getInputSocketReader(0);
+	this->inputZProgram = getInputSocketReader(1);
+	this->inputSpeedProgram = getInputSocketReader(2);
+	this->cachedInstance = NULL;
+}
+
+void VectorBlurOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+	float* buffer = (float*) data;
+	int index = (y*this->getWidth() + x) * COM_NUMBER_OF_CHANNELS;
+	color[0] = buffer[index];
+	color[1] = buffer[index+1];
+	color[2] = buffer[index+2];
+	color[3] = buffer[index+3];
+}
+
+void VectorBlurOperation::deinitExecution() {
+	deinitMutex();
+	this->inputImageProgram = NULL;
+	this->inputSpeedProgram = NULL;
+	this->inputZProgram = NULL;
+	if (this->cachedInstance) {
+		delete cachedInstance;
+		this->cachedInstance = NULL;
+	}
+}

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list