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

Jeroen Bakker j.bakker at atmind.nl
Wed Jan 4 15:43:27 CET 2012


Revision: 43128
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43128
Author:   jbakker
Date:     2012-01-04 14:43:26 +0000 (Wed, 04 Jan 2012)
Log Message:
-----------
TileBranch
 * added the basic implementation of the GlareNode
 * only implemented the FogGlow
 * all others will also do fogglow

FogGlowImageOperation calculates a BokehImage for the glow. This way the BokehBlur is reused to calculate the actual blur
GlareThresholdOperation will generate the image where the effect must take place. (BTL function in the old compositor)

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_GlareNode.cpp
    branches/tile/source/blender/compositor/nodes/COM_GlareNode.h
    branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.h
    branches/tile/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_GlareThresholdOperation.h

Modified: branches/tile/source/blender/compositor/CMakeLists.txt
===================================================================
--- branches/tile/source/blender/compositor/CMakeLists.txt	2012-01-04 14:42:11 UTC (rev 43127)
+++ branches/tile/source/blender/compositor/CMakeLists.txt	2012-01-04 14:43:26 UTC (rev 43128)
@@ -155,6 +155,8 @@
 		nodes/COM_LensDistortionNode.cpp
 		nodes/COM_LensDistortionNode.h
 
+		nodes/COM_GlareNode.cpp
+		nodes/COM_GlareNode.h
 		nodes/COM_LensFlareNode.cpp
 		nodes/COM_LensFlareNode.h
 
@@ -163,6 +165,7 @@
 		operations/COM_LensGhostOperation.cpp
 		operations/COM_LensGhostOperation.h
 
+
 # color nodes
 		nodes/COM_VectorCurveNode.cpp
 		nodes/COM_VectorCurveNode.h
@@ -446,12 +449,16 @@
 		operations/COM_ScreenLensDistortionOperation.h
 
 #Filter operations
-		operations/COM_ConvolutionFilterOperation.h
-		operations/COM_ConvolutionFilterOperation.cpp
-		operations/COM_ConvolutionEdgeFilterOperation.h
-		operations/COM_ConvolutionEdgeFilterOperation.cpp
-		operations/COM_DilateErodeOperation.cpp
-		operations/COM_DilateErodeOperation.h
+	operations/COM_ConvolutionFilterOperation.h
+	operations/COM_ConvolutionFilterOperation.cpp
+	operations/COM_ConvolutionEdgeFilterOperation.h
+	operations/COM_ConvolutionEdgeFilterOperation.cpp
+	operations/COM_DilateErodeOperation.cpp
+	operations/COM_DilateErodeOperation.h
+	operations/COM_FogGlowImageOperation.cpp
+	operations/COM_FogGlowImageOperation.h
+	operations/COM_GlareThresholdOperation.cpp
+	operations/COM_GlareThresholdOperation.h
 
 
 #Convert operations

Modified: branches/tile/source/blender/compositor/intern/COM_Converter.cpp
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-01-04 14:42:11 UTC (rev 43127)
+++ branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-01-04 14:43:26 UTC (rev 43128)
@@ -88,6 +88,7 @@
 #include "COM_TonemapNode.h"
 #include "COM_SwitchNode.h"
 #include "COM_OpenCLTestNode.h"
+#include "COM_GlareNode.h"
 
 Node* Converter::convert(bNode *bNode) {
 	Node * node;
@@ -252,6 +253,9 @@
 	case CMP_NODE_OPENCLTEST:
 		node = new OpenCLTestNode(bNode);
 		break;
+	case CMP_NODE_GLARE:
+		node = new GlareNode(bNode);
+		break;
 	default:
 		node = new MuteNode(bNode);
 		break;

Added: branches/tile/source/blender/compositor/nodes/COM_GlareNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_GlareNode.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_GlareNode.cpp	2012-01-04 14:43:26 UTC (rev 43128)
@@ -0,0 +1,72 @@
+/*
+ * 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_GlareNode.h"
+#include "DNA_node_types.h"
+#include "COM_FogGlowImageOperation.h"
+#include "COM_BokehBlurOperation.h"
+#include "COM_GlareThresholdOperation.h"
+#include "COM_SetValueOperation.h"
+#include "COM_MixBlendOperation.h"
+
+GlareNode::GlareNode(bNode *editorNode): Node(editorNode) {
+}
+
+void GlareNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) {
+	bNode* node = this->getbNode();
+	NodeGlare* glare = (NodeGlare*)node->storage;
+	
+	switch (glare->type) {
+	default:
+	case 1: // fog glow
+		GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
+		FogGlowImageOperation * kerneloperation = new FogGlowImageOperation();
+		BokehBlurOperation * bluroperation = new BokehBlurOperation();
+		SetValueOperation * valueoperation = new SetValueOperation();
+		SetValueOperation * mixvalueoperation = new SetValueOperation();
+		MixBlendOperation * mixoperation = new MixBlendOperation();
+		mixoperation->setResolutionInputSocketIndex(1);
+		this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), true, 0, system);
+		addLink(system, thresholdOperation->getOutputSocket(), bluroperation->getInputSocket(0));
+		addLink(system, kerneloperation->getOutputSocket(), bluroperation->getInputSocket(1));
+		addLink(system, valueoperation->getOutputSocket(), bluroperation->getInputSocket(2));
+		addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
+		addLink(system, bluroperation->getOutputSocket(), mixoperation->getInputSocket(2));
+		addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1));
+
+		thresholdOperation->setThreshold(glare->threshold);
+		bluroperation->setSize(0.003f*glare->size);
+		bluroperation->setQuality(context->getQuality());
+		valueoperation->setValue(1.0f);
+		mixvalueoperation->setValue(0.5f+glare->mix*0.5f);
+		this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
+
+		system->addOperation(bluroperation);
+		system->addOperation(kerneloperation);
+		system->addOperation(thresholdOperation);
+		system->addOperation(mixvalueoperation);
+		system->addOperation(valueoperation);
+		system->addOperation(mixoperation);
+
+		break;
+	}
+}

Added: branches/tile/source/blender/compositor/nodes/COM_GlareNode.h
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_GlareNode.h	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_GlareNode.h	2012-01-04 14:43:26 UTC (rev 43128)
@@ -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_GlareNode_h_
+#define _COM_GlareNode_h_
+
+#include "COM_Node.h"
+
+/**
+  * @brief GlareNode
+  * @ingroup Node
+  */
+class GlareNode: public Node {
+public:
+	GlareNode(bNode *editorNode);
+    void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif

Added: branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp	2012-01-04 14:43:26 UTC (rev 43128)
@@ -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
+ * 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_FogGlowImageOperation.h"
+#include "COM_InputSocket.h"
+#include "COM_OutputSocket.h"
+#include "BLI_math.h"
+
+FogGlowImageOperation::FogGlowImageOperation(): NodeOperation() {
+	this->addOutputSocket(COM_DT_COLOR);
+}
+void FogGlowImageOperation::initExecution() {
+}
+
+void FogGlowImageOperation::executePixel(float* color, float x, float y, MemoryBuffer *inputBuffers[]) {
+	const float cs_r = 1.f, cs_g = 1.f, cs_b = 1.f;
+
+	float u, v, w, d, r;
+	
+	v = 2.f*(y / (float)512) - 1.f;
+	u = 2.f*(x / (float)512) - 1.f;
+	r = (u*u + v*v)*256;
+	d = -sqrtf(sqrtf(sqrtf(r)));
+	w = (0.5f + 0.5f*cos((double)u*M_PI))*(0.5f + 0.5f*cos((double)v*M_PI));
+	color[0] = expf(d*cs_r) * w;
+	color[1] = expf(d*cs_g) * w;
+	color[2] = expf(d*cs_b) * w;
+	color[3] = 1.0f;
+}
+
+void FogGlowImageOperation::deinitExecution() {
+}
+
+void FogGlowImageOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+	resolution[0] = 512;
+	resolution[1] = 512;
+}

Added: branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.h
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.h	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_FogGlowImageOperation.h	2012-01-04 14:43:26 UTC (rev 43128)
@@ -0,0 +1,54 @@
+/*
+ * 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

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list