[Bf-blender-cvs] [658b4c0] master: New Corner Pin node: uses explicit corner values for a plane warp transformation.

Lukas Tönne noreply at git.blender.org
Tue Mar 11 14:29:50 CET 2014


Commit: 658b4c0d56dffbcf1476c2a2a019fa0ecfb79376
Author: Lukas Tönne
Date:   Tue Mar 11 14:07:49 2014 +0100
https://developer.blender.org/rB658b4c0d56dffbcf1476c2a2a019fa0ecfb79376

New Corner Pin node: uses explicit corner values for a plane warp transformation.

This was suggested by Christopher Barrett (terrachild). Corner pin is a common feature in compositing.

The corners for the plane warping can be defined by using vector node inputs to allow using perspective plane transformations without having to go via the MovieClip editor tracking data.
Uses the same math as the PlaneTrack node, but without the link to MovieClip and Object.

{F78199}

The code for PlaneTrack operations has been restructured a bit to share it with the CornerPin node.

* PlaneDistortCommonOperation.h/.cpp: Shared generic code for warping images based on 4 plane corners and a perspective matrix generated from these. Contains operation base classes for both the WarpImage and Mask operations.

* PlaneTrackOperation.h/.cpp: Current plane track node operations, based on the common code above. These add pointers to MovieClip and Object which define the track data from wich to read the corners.

* PlaneCornerPinOperation.h/.cpp: New corner pin variant, using explicit input sockets for the plane corners.

One downside of the current compositor design is that there is no concept of invariables (constants) that don't vary over the image space. This has already been an issue for Blur nodes (size input is usually constant except when "variable size" is enabled) and a few others. For the corner pin node it is necessary that the corner input sockets are also invariant. They have to be evaluated for each tile now, otherwise the data is not available. This in turn makes it necessary to make the op [...]

===================================================================

M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/intern/node.c
M	source/blender/compositor/CMakeLists.txt
M	source/blender/compositor/intern/COM_Converter.cpp
A	source/blender/compositor/nodes/COM_CornerPinNode.cpp
A	source/blender/compositor/nodes/COM_CornerPinNode.h
M	source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp
A	source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
A	source/blender/compositor/operations/COM_PlaneCornerPinOperation.h
A	source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp
A	source/blender/compositor/operations/COM_PlaneDistortCommonOperation.h
D	source/blender/compositor/operations/COM_PlaneTrackCommonOperation.cpp
D	source/blender/compositor/operations/COM_PlaneTrackCommonOperation.h
D	source/blender/compositor/operations/COM_PlaneTrackMaskOperation.cpp
D	source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h
A	source/blender/compositor/operations/COM_PlaneTrackOperation.cpp
A	source/blender/compositor/operations/COM_PlaneTrackOperation.h
D	source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp
D	source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h
M	source/blender/editors/space_node/drawnode.c
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_composite.h
M	source/blender/nodes/NOD_static_types.h
A	source/blender/nodes/composite/nodes/node_composite_cornerpin.c

===================================================================

diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 6ade491..be989f0 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -349,6 +349,7 @@ compositor_node_categories = [
         NodeItem("CompositorNodeTransform"),
         NodeItem("CompositorNodeStabilize"),
         NodeItem("CompositorNodePlaneTrackDeform"),
+        NodeItem("CompositorNodeCornerPin"),
         ]),
     CompositorNodeCategory("CMP_GROUP", "Group", items=node_group_items),
     CompositorNodeCategory("CMP_LAYOUT", "Layout", items=[
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 59ea921..af912b9 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -897,6 +897,7 @@ void            ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMateria
 
 #define CMP_NODE_MAP_RANGE	319
 #define CMP_NODE_PLANETRACKDEFORM	320
+#define CMP_NODE_CORNERPIN          321
 
 /* channel toggles */
 #define CMP_CHAN_RGB		1
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index d622556..249fb52 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -3460,6 +3460,7 @@ static void registerCompositNodes(void)
 	register_node_type_cmp_mask();
 	register_node_type_cmp_trackpos();
 	register_node_type_cmp_planetrackdeform();
+	register_node_type_cmp_cornerpin();
 }
 
 static void registerShaderNodes(void) 
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index 11add97..cbb1017 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -185,6 +185,8 @@ set(SRC
 	nodes/COM_GlareNode.cpp
 	nodes/COM_GlareNode.h
 
+	nodes/COM_CornerPinNode.cpp
+	nodes/COM_CornerPinNode.h
 	nodes/COM_PlaneTrackDeformNode.cpp
 	nodes/COM_PlaneTrackDeformNode.h
 
@@ -488,12 +490,12 @@ set(SRC
 	operations/COM_ProjectorLensDistortionOperation.h
 	operations/COM_ScreenLensDistortionOperation.cpp
 	operations/COM_ScreenLensDistortionOperation.h
-	operations/COM_PlaneTrackCommonOperation.cpp
-	operations/COM_PlaneTrackCommonOperation.h
-	operations/COM_PlaneTrackMaskOperation.cpp
-	operations/COM_PlaneTrackMaskOperation.h
-	operations/COM_PlaneTrackWarpImageOperation.cpp
-	operations/COM_PlaneTrackWarpImageOperation.h
+	operations/COM_PlaneDistortCommonOperation.cpp
+	operations/COM_PlaneDistortCommonOperation.h
+	operations/COM_PlaneTrackOperation.cpp
+	operations/COM_PlaneTrackOperation.h
+	operations/COM_PlaneCornerPinOperation.cpp
+	operations/COM_PlaneCornerPinOperation.h
 
 	#Filter operations
 	operations/COM_ConvolutionFilterOperation.h
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index 384cfbe..7103b49 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -49,6 +49,7 @@
 #include "COM_ConvertAlphaNode.h"
 #include "COM_ConvertOperation.h"
 #include "COM_Converter.h"
+#include "COM_CornerPinNode.h"
 #include "COM_CropNode.h"
 #include "COM_DefocusNode.h"
 #include "COM_DespeckleNode.h"
@@ -401,6 +402,9 @@ Node *Converter::convert(bNode *b_node, bool fast)
 		case CMP_NODE_PLANETRACKDEFORM:
 			node = new PlaneTrackDeformNode(b_node);
 			break;
+		case CMP_NODE_CORNERPIN:
+			node = new CornerPinNode(b_node);
+			break;
 		default:
 			node = new MuteNode(b_node);
 			break;
diff --git a/source/blender/compositor/nodes/COM_CornerPinNode.cpp b/source/blender/compositor/nodes/COM_CornerPinNode.cpp
new file mode 100644
index 0000000..3115be8
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CornerPinNode.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2014, 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:
+ *		Lukas Toenne
+ */
+
+#include "COM_CornerPinNode.h"
+#include "COM_ExecutionSystem.h"
+
+#include "COM_PlaneCornerPinOperation.h"
+
+CornerPinNode::CornerPinNode(bNode *editorNode) : Node(editorNode)
+{
+}
+
+void CornerPinNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+{
+	InputSocket *input_image = this->getInputSocket(0);
+	/* note: socket order differs between UI node and operations:
+	 * bNode uses intuitive order following top-down layout:
+	 *   upper-left, upper-right, lower-left, lower-right
+	 * Operations use same order as the tracking blenkernel functions expect:
+	 *   lower-left, lower-right, upper-right, upper-left
+	 */
+	const int node_corner_index[4] = { 3, 4, 2, 1 };
+
+	OutputSocket *output_warped_image = this->getOutputSocket(0);
+	OutputSocket *output_plane = this->getOutputSocket(1);
+
+	PlaneCornerPinWarpImageOperation *warp_image_operation = new PlaneCornerPinWarpImageOperation();
+	
+	input_image->relinkConnections(warp_image_operation->getInputSocket(0), 0, graph);
+	for (int i = 0; i < 4; ++i) {
+		int node_index = node_corner_index[i];
+		getInputSocket(node_index)->relinkConnections(warp_image_operation->getInputSocket(i+1),
+		                                              node_index, graph);
+	}
+	output_warped_image->relinkConnections(warp_image_operation->getOutputSocket());
+	
+	graph->addOperation(warp_image_operation);
+	
+	PlaneCornerPinMaskOperation *plane_mask_operation = new PlaneCornerPinMaskOperation();
+	
+	/* connect mask op inputs to the same sockets as the warp image op */
+	for (int i = 0; i < 4; ++i)
+		addLink(graph,
+		        warp_image_operation->getInputSocket(i+1)->getConnection()->getFromSocket(),
+		        plane_mask_operation->getInputSocket(i));
+	output_plane->relinkConnections(plane_mask_operation->getOutputSocket());
+	
+	graph->addOperation(plane_mask_operation);
+}
diff --git a/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h b/source/blender/compositor/nodes/COM_CornerPinNode.h
similarity index 56%
rename from source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h
rename to source/blender/compositor/nodes/COM_CornerPinNode.h
index 7f76395..b8b8a16 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h
+++ b/source/blender/compositor/nodes/COM_CornerPinNode.h
@@ -1,6 +1,5 @@
-
 /*
- * Copyright 2013, Blender Foundation.
+ * Copyright 2014, Blender Foundation.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -17,33 +16,26 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  * Contributor:
- *		Sergey Sharybin
+ *		Lukas Toenne
  */
 
-#ifndef _COM_PlaneTrackMaskOperation_h
-#define _COM_PlaneTrackMaskOperation_h
-
-#include <string.h>
-
-#include "COM_PlaneTrackCommonOperation.h"
-
-#include "DNA_movieclip_types.h"
-#include "DNA_tracking_types.h"
+#ifndef _COM_CornerPinNode_h
+#define _COM_CornerPinNode_h
 
-#include "BLI_listbase.h"
-#include "BLI_string.h"
+#include "COM_Node.h"
 
-class PlaneTrackMaskOperation : public PlaneTrackCommonOperation {
-protected:
-	int m_osa;
-	float m_jitter[32][2];
+extern "C" {
+#include "DNA_node_types.h"
+}
 
+/**
+ * @brief CornerPinNode
+ * @ingroup Node
+ */
+class CornerPinNode : public Node {
 public:
-	PlaneTrackMaskOperation();
-
-	void initExecution();
-
-	void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+	CornerPinNode(bNode *editorNode);
+	void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
 };
 
-#endif
+#endif /* _COM_CornerPinNode_h */
diff --git a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp
index f52c696..944e04e 100644
--- a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp
+++ b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp
@@ -24,8 +24,7 @@
 #include "COM_PlaneTrackDeformNode.h"
 #include "COM_ExecutionSystem.h"
 
-#include "COM_PlaneTrackMaskOperation.h"
-#include "COM_PlaneTrackWarpImageOperation.h"
+#include "COM_PlaneTrackOperation.h"
 
 extern "C" {
 #  include "BKE_node.h"
diff --git a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
new file mode 100644
index 0000000..fe27200
--- /dev/null
+++ b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
@@ -0,0 +1,223 @@
+/*
+ * Copyright 2014, 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:
+ *		Lukas Toenne
+ */
+
+#include "COM_PlaneCornerPinOperation.h"
+#include "COM_ReadBufferOperation.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_math_color.h"
+
+extern "C" {
+#  incl

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list