[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52214] trunk/blender/source/blender: Map Range Node (tiles)

Dalai Felinto dfelinto at gmail.com
Wed Nov 14 20:53:46 CET 2012


Revision: 52214
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52214
Author:   dfelinto
Date:     2012-11-14 19:53:46 +0000 (Wed, 14 Nov 2012)
Log Message:
-----------
Map Range Node (tiles)
this node allows for more control for normalization of the mapped input range.

Made during BlenderPRO 2012 - Brasilia, Brazil :)
Idea and testing: Daniel Salazar
Implementation: yours truly
Reviewed by Lukas Toenne and Sergey Sharybin

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_node.h
    trunk/blender/source/blender/blenkernel/intern/node.c
    trunk/blender/source/blender/compositor/CMakeLists.txt
    trunk/blender/source/blender/compositor/intern/COM_Converter.cpp
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/makesrna/RNA_access.h
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
    trunk/blender/source/blender/makesrna/intern/rna_nodetree_types.h
    trunk/blender/source/blender/nodes/CMakeLists.txt
    trunk/blender/source/blender/nodes/NOD_composite.h

Added Paths:
-----------
    trunk/blender/source/blender/compositor/nodes/COM_MapRangeNode.cpp
    trunk/blender/source/blender/compositor/nodes/COM_MapRangeNode.h
    trunk/blender/source/blender/compositor/operations/COM_MapRangeOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_MapRangeOperation.h
    trunk/blender/source/blender/nodes/composite/nodes/node_composite_mapRange.c

Modified: trunk/blender/source/blender/blenkernel/BKE_node.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_node.h	2012-11-14 19:10:12 UTC (rev 52213)
+++ trunk/blender/source/blender/blenkernel/BKE_node.h	2012-11-14 19:53:46 UTC (rev 52214)
@@ -706,6 +706,8 @@
 #define CMP_NODE_SWITCH         317
 #define CMP_NODE_PIXELATE       318
 
+#define CMP_NODE_MAP_RANGE	319
+
 /* channel toggles */
 #define CMP_CHAN_RGB		1
 #define CMP_CHAN_A			2

Modified: trunk/blender/source/blender/blenkernel/intern/node.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/node.c	2012-11-14 19:10:12 UTC (rev 52213)
+++ trunk/blender/source/blender/blenkernel/intern/node.c	2012-11-14 19:53:46 UTC (rev 52214)
@@ -2184,6 +2184,7 @@
 	register_node_type_cmp_normal(ttype);
 	register_node_type_cmp_curve_vec(ttype);
 	register_node_type_cmp_map_value(ttype);
+	register_node_type_cmp_map_range(ttype);
 	register_node_type_cmp_normalize(ttype);
 	
 	register_node_type_cmp_filter(ttype);

Modified: trunk/blender/source/blender/compositor/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/compositor/CMakeLists.txt	2012-11-14 19:10:12 UTC (rev 52213)
+++ trunk/blender/source/blender/compositor/CMakeLists.txt	2012-11-14 19:53:46 UTC (rev 52214)
@@ -267,6 +267,8 @@
 	nodes/COM_MathNode.h
 	nodes/COM_MapValueNode.cpp
 	nodes/COM_MapValueNode.h
+	nodes/COM_MapRangeNode.cpp
+	nodes/COM_MapRangeNode.h
 
 	operations/COM_NormalizeOperation.cpp
 	operations/COM_NormalizeOperation.h
@@ -572,6 +574,8 @@
 	operations/COM_SetAlphaOperation.h
 	operations/COM_MapValueOperation.cpp
 	operations/COM_MapValueOperation.h
+	operations/COM_MapRangeOperation.cpp
+	operations/COM_MapRangeOperation.h
 
 	# Distort operation
 	operations/COM_TranslateOperation.h

Modified: trunk/blender/source/blender/compositor/intern/COM_Converter.cpp
===================================================================
--- trunk/blender/source/blender/compositor/intern/COM_Converter.cpp	2012-11-14 19:10:12 UTC (rev 52213)
+++ trunk/blender/source/blender/compositor/intern/COM_Converter.cpp	2012-11-14 19:53:46 UTC (rev 52214)
@@ -83,6 +83,7 @@
 #include "COM_LuminanceMatteNode.h"
 #include "COM_MapUVNode.h"
 #include "COM_MapValueNode.h"
+#include "COM_MapRangeNode.h"
 #include "COM_MaskNode.h"
 #include "COM_MathNode.h"
 #include "COM_MixNode.h"
@@ -351,6 +352,9 @@
 		case CMP_NODE_MAP_VALUE:
 			node = new MapValueNode(b_node);
 			break;
+		case CMP_NODE_MAP_RANGE:
+			node = new MapRangeNode(b_node);
+			break;
 		case CMP_NODE_TRANSFORM:
 			node = new TransformNode(b_node);
 			break;

Added: trunk/blender/source/blender/compositor/nodes/COM_MapRangeNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_MapRangeNode.cpp	                        (rev 0)
+++ trunk/blender/source/blender/compositor/nodes/COM_MapRangeNode.cpp	2012-11-14 19:53:46 UTC (rev 52214)
@@ -0,0 +1,54 @@
+/*
+ * 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
+ *		Daniel Salazar
+ */
+
+#include "COM_MapRangeNode.h"
+
+#include "COM_MapRangeOperation.h"
+#include "COM_ExecutionSystem.h"
+
+MapRangeNode::MapRangeNode(bNode *editorNode) : Node(editorNode)
+{
+	/* pass */
+}
+
+void MapRangeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+{
+	InputSocket *valueSocket = this->getInputSocket(0);
+	InputSocket *sourceMinSocket = this->getInputSocket(1);
+	InputSocket *sourceMaxSocket = this->getInputSocket(2);
+	InputSocket *destMinSocket = this->getInputSocket(3);
+	InputSocket *destMaxSocket = this->getInputSocket(4);
+	OutputSocket *outputSocket = this->getOutputSocket(0);
+
+	MapRangeOperation *operation = new MapRangeOperation();
+
+	valueSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
+	sourceMinSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
+	sourceMaxSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
+	destMinSocket->relinkConnections(operation->getInputSocket(3), 3, graph);
+	destMaxSocket->relinkConnections(operation->getInputSocket(4), 4, graph);
+	outputSocket->relinkConnections(operation->getOutputSocket(0));
+
+	operation->setUseClamp(this->getbNode()->custom1);
+
+	graph->addOperation(operation);
+}


Property changes on: trunk/blender/source/blender/compositor/nodes/COM_MapRangeNode.cpp
___________________________________________________________________
Added: svn:eol
   + native

Added: trunk/blender/source/blender/compositor/nodes/COM_MapRangeNode.h
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_MapRangeNode.h	                        (rev 0)
+++ trunk/blender/source/blender/compositor/nodes/COM_MapRangeNode.h	2012-11-14 19:53:46 UTC (rev 52214)
@@ -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
+ *		Daniel Salazar
+ */
+
+#ifndef __COM_MAPRANGENODE_H__
+#define __COM_MAPRANGENODE_H__
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+/**
+ * @brief MapRangeNode
+ * @ingroup Node
+ */
+class MapRangeNode : public Node {
+public:
+	MapRangeNode(bNode *editorNode);
+	void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif  /* __COM_MAPRANGENODE_H__ */


Property changes on: trunk/blender/source/blender/compositor/nodes/COM_MapRangeNode.h
___________________________________________________________________
Added: svn:eol
   + native

Added: trunk/blender/source/blender/compositor/operations/COM_MapRangeOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_MapRangeOperation.cpp	                        (rev 0)
+++ trunk/blender/source/blender/compositor/operations/COM_MapRangeOperation.cpp	2012-11-14 19:53:46 UTC (rev 52214)
@@ -0,0 +1,81 @@
+/*
+ * 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
+ *		Daniel Salazar
+ */
+
+#include "COM_MapRangeOperation.h"
+
+MapRangeOperation::MapRangeOperation() : NodeOperation()
+{
+	this->addInputSocket(COM_DT_VALUE);
+	this->addInputSocket(COM_DT_VALUE);
+	this->addInputSocket(COM_DT_VALUE);
+	this->addInputSocket(COM_DT_VALUE);
+	this->addInputSocket(COM_DT_VALUE);
+	this->addOutputSocket(COM_DT_VALUE);
+	this->m_inputOperation = NULL;
+	this->m_useClamp = FALSE;
+}
+
+void MapRangeOperation::initExecution()
+{
+	this->m_inputOperation = this->getInputSocketReader(0);
+	this->m_sourceMinOperation = this->getInputSocketReader(1);
+	this->m_sourceMaxOperation = this->getInputSocketReader(2);
+	this->m_destMinOperation = this->getInputSocketReader(3);
+	this->m_destMaxOperation = this->getInputSocketReader(4);
+}
+
+void MapRangeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+{
+	float inputs[8]; /* includes the 5 inputs + 3 pads */
+	float value;
+	float source_min, source_max;
+	float dest_min, dest_max;
+
+	this->m_inputOperation->read(inputs, x, y, sampler);
+	this->m_sourceMinOperation->read(inputs+1, x, y, sampler);
+	this->m_sourceMaxOperation->read(inputs+2, x, y, sampler);
+	this->m_destMinOperation->read(inputs+3, x, y, sampler);
+	this->m_destMaxOperation->read(inputs+4, x, y, sampler);
+	
+	value = inputs[0];
+	source_min = inputs[1];
+	source_max = inputs[2];
+	dest_min = inputs[3];
+	dest_max = inputs[4];
+	
+	value = (value - source_min) / (source_max - source_min);
+	value = dest_min + value * (dest_max - dest_min);
+
+	if (this->m_useClamp)
+		CLAMP(value, dest_min, dest_max);
+
+	output[0] = value;
+}
+
+void MapRangeOperation::deinitExecution()
+{
+	this->m_inputOperation = NULL;
+	this->m_sourceMinOperation = NULL;
+	this->m_sourceMaxOperation = NULL;
+	this->m_destMinOperation = NULL;
+	this->m_destMaxOperation = NULL;
+}


Property changes on: trunk/blender/source/blender/compositor/operations/COM_MapRangeOperation.cpp
___________________________________________________________________
Added: svn:eol
   + native

Added: trunk/blender/source/blender/compositor/operations/COM_MapRangeOperation.h

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list