[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49280] trunk/blender/source/blender: mask motion blur shutter option

Campbell Barton ideasman42 at gmail.com
Fri Jul 27 12:20:36 CEST 2012


Revision: 49280
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49280
Author:   campbellbarton
Date:     2012-07-27 10:20:36 +0000 (Fri, 27 Jul 2012)
Log Message:
-----------
mask motion blur shutter option

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_blender.h
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/compositor/nodes/COM_MaskNode.cpp
    trunk/blender/source/blender/compositor/operations/COM_MaskOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_MaskOperation.h
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/makesdna/DNA_node_types.h
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
    trunk/blender/source/blender/nodes/composite/nodes/node_composite_mask.c

Modified: trunk/blender/source/blender/blenkernel/BKE_blender.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_blender.h	2012-07-27 10:12:58 UTC (rev 49279)
+++ trunk/blender/source/blender/blenkernel/BKE_blender.h	2012-07-27 10:20:36 UTC (rev 49280)
@@ -42,7 +42,7 @@
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         263
-#define BLENDER_SUBVERSION      16
+#define BLENDER_SUBVERSION      17
 
 #define BLENDER_MINVERSION      250
 #define BLENDER_MINSUBVERSION   0

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2012-07-27 10:12:58 UTC (rev 49279)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2012-07-27 10:20:36 UTC (rev 49280)
@@ -7027,6 +7027,24 @@
 	}
 }
 
+static void do_version_ntree_mask_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
+{
+	bNode *node;
+
+	for (node = ntree->nodes.first; node; node = node->next) {
+		if (node->type == CMP_NODE_MASK) {
+			if (node->storage == NULL) {
+				NodeMask *data = MEM_callocN(sizeof(NodeMask), __func__);
+				/* move settings into own struct */
+				data->size_x = node->custom3;
+				data->size_y = node->custom4;
+				node->custom3 = 0.5f; /* default shutter */
+				node->storage = data;
+			}
+		}
+	}
+}
+
 static void do_version_ntree_keying_despill_balance(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
 {
 	bNode *node;
@@ -7863,6 +7881,13 @@
 			ntreetype->foreach_nodetree(main, NULL, do_version_ntree_keying_despill_balance);
 	}
 
+	if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 17)) {
+		bNodeTreeType *ntreetype = ntreeGetType(NTREE_COMPOSIT);
+
+		if (ntreetype && ntreetype->foreach_nodetree)
+			ntreetype->foreach_nodetree(main, NULL, do_version_ntree_mask_264);
+	}
+
 	/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
 	/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
 

Modified: trunk/blender/source/blender/compositor/nodes/COM_MaskNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_MaskNode.cpp	2012-07-27 10:12:58 UTC (rev 49279)
+++ trunk/blender/source/blender/compositor/nodes/COM_MaskNode.cpp	2012-07-27 10:20:36 UTC (rev 49280)
@@ -36,11 +36,12 @@
 
 void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
 {
-	const RenderData *data = context->getRenderData();
+	const RenderData *rd = context->getRenderData();
 
 	OutputSocket *outputMask = this->getOutputSocket(0);
 
 	bNode *editorNode = this->getbNode();
+	NodeMask *data = (NodeMask *)editorNode->storage;
 	Mask *mask = (Mask *)editorNode->id;
 
 	// always connect the output image
@@ -48,16 +49,16 @@
 	operation->setbNode(editorNode);
 
 	if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED) {
-		operation->setMaskWidth(editorNode->custom3);
-		operation->setMaskHeight(editorNode->custom4);
+		operation->setMaskWidth(data->size_x);
+		operation->setMaskHeight(data->size_y);
 	}
 	else if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED_SCENE) {
-		operation->setMaskWidth(editorNode->custom3 * (data->size / 100.0f));
-		operation->setMaskHeight(editorNode->custom4 * (data->size / 100.0f));
+		operation->setMaskWidth(data->size_x * (rd->size / 100.0f));
+		operation->setMaskHeight(data->size_y * (rd->size / 100.0f));
 	}
 	else {
-		operation->setMaskWidth(data->xsch * data->size / 100.0f);
-		operation->setMaskHeight(data->ysch * data->size / 100.0f);
+		operation->setMaskWidth(rd->xsch * rd->size / 100.0f);
+		operation->setMaskHeight(rd->ysch * rd->size / 100.0f);
 	}
 
 	if (outputMask->isConnected()) {
@@ -69,8 +70,12 @@
 	operation->setSmooth((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_AA) != 0);
 	operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0);
 
-	if (editorNode->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) {
+	if ((editorNode->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) &&
+	    (editorNode->custom2 > 1) &&
+	    (editorNode->custom3 > FLT_EPSILON))
+	{
 		operation->setMotionBlurSamples(editorNode->custom2);
+		operation->setMotionBlurShutter(editorNode->custom3);
 	}
 
 	graph->addOperation(operation);

Modified: trunk/blender/source/blender/compositor/operations/COM_MaskOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_MaskOperation.cpp	2012-07-27 10:12:58 UTC (rev 49279)
+++ trunk/blender/source/blender/compositor/operations/COM_MaskOperation.cpp	2012-07-27 10:20:36 UTC (rev 49280)
@@ -139,7 +139,8 @@
 	this->m_maskHeight = 0;
 	this->m_maskWidthInv = 0.0f;
 	this->m_maskHeightInv = 0.0f;
-	this->m_framenumber = 0;
+	this->m_frame_shutter = 0.0f;
+	this->m_frame_number = 0;
 	this->m_rasterMaskHandleTot = 1;
 	memset(this->m_rasterMaskHandles, 0, sizeof(this->m_rasterMaskHandles));
 }
@@ -156,9 +157,8 @@
 		}
 		else {
 			/* make a throw away copy of the mask */
-			const float frame_range = 1.0f; /* should be 1 max, could be configurable */
-			const float frame = (float)this->m_framenumber - frame_range;
-			const float frame_step = (frame_range * 2.0f) / this->m_rasterMaskHandleTot;
+			const float frame = (float)this->m_frame_number - this->m_frame_shutter;
+			const float frame_step = (this->m_frame_shutter * 2.0f) / this->m_rasterMaskHandleTot;
 			float frame_iter = frame;
 
 			Mask *mask_temp;
@@ -174,7 +174,7 @@
 				     masklay;
 				     masklay = (MaskLayer *)masklay->next)
 				{
-					masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, this->m_framenumber);
+					masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, this->m_frame_number);
 					BKE_mask_layer_shape_from_mask(masklay, masklay_shape);
 				}
 			}

Modified: trunk/blender/source/blender/compositor/operations/COM_MaskOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_MaskOperation.h	2012-07-27 10:12:58 UTC (rev 49279)
+++ trunk/blender/source/blender/compositor/operations/COM_MaskOperation.h	2012-07-27 10:20:36 UTC (rev 49280)
@@ -54,7 +54,9 @@
 	float m_maskWidthInv;  /* 1 / m_maskWidth  */
 	float m_maskHeightInv; /* 1 / m_maskHeight */
 
-	int m_framenumber;
+	float m_frame_shutter;
+	int   m_frame_number;
+
 	bool m_do_smooth;
 	bool m_do_feather;
 
@@ -91,10 +93,12 @@
 		this->m_maskHeight = height;
 		this->m_maskHeightInv = 1.0f / (float)height;
 	}
-	void setFramenumber(int framenumber) { this->m_framenumber = framenumber; }
+	void setFramenumber(int frame_number) { this->m_frame_number = frame_number; }
 	void setSmooth(bool smooth) { this->m_do_smooth = smooth; }
 	void setFeather(bool feather) { this->m_do_feather = feather; }
+
 	void setMotionBlurSamples(int samples) { this->m_rasterMaskHandleTot = max(1, samples); }
+	void setMotionBlurShutter(float shutter) { this->m_frame_shutter = shutter; }
 
 #ifdef USE_RASKTER
 	void *initializeTileData(rcti *rect);

Modified: trunk/blender/source/blender/editors/space_node/drawnode.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/drawnode.c	2012-07-27 10:12:58 UTC (rev 49279)
+++ trunk/blender/source/blender/editors/space_node/drawnode.c	2012-07-27 10:20:36 UTC (rev 49280)
@@ -2506,6 +2506,7 @@
 	uiItemR(layout, ptr, "use_motion_blur", 0, NULL, ICON_NONE);
 	if (node->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) {
 		uiItemR(layout, ptr, "motion_blur_samples", 0, NULL, ICON_NONE);
+		uiItemR(layout, ptr, "motion_blur_shutter", 0, NULL, ICON_NONE);
 	}
 }
 

Modified: trunk/blender/source/blender/makesdna/DNA_node_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_node_types.h	2012-07-27 10:12:58 UTC (rev 49279)
+++ trunk/blender/source/blender/makesdna/DNA_node_types.h	2012-07-27 10:20:36 UTC (rev 49280)
@@ -589,6 +589,10 @@
 	char pad[7];
 } NodeDilateErode;
 
+typedef struct NodeMask {
+	int size_x, size_y;
+} NodeMask;
+
 typedef struct NodeTexBase {
 	TexMapping tex_mapping;
 	ColorMapping color_mapping;

Modified: trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_nodetree.c	2012-07-27 10:12:58 UTC (rev 49279)
+++ trunk/blender/source/blender/makesrna/intern/rna_nodetree.c	2012-07-27 10:20:36 UTC (rev 49280)
@@ -3195,20 +3195,28 @@
 	RNA_def_property_ui_text(prop, "Samples", "Number of motion blur samples");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 
+	prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "custom3");
+	RNA_def_property_range(prop, 0.0, 1.0f);
+	RNA_def_property_ui_text(prop, "Shutter", "Exposure for motion blur as a factor of FPS");
+	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+
 	prop = RNA_def_property(srna, "size_source", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_bitflag_sdna(prop, NULL, "custom1");
 	RNA_def_property_enum_items(prop, aspect_type_items);
 	RNA_def_property_ui_text(prop, "Size Source", "Where to get the mask size from for aspect/size information");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 
+
+	RNA_def_struct_sdna_from(srna, "NodeMask", "storage");
+
 	prop = RNA_def_property(srna, "size_x", PROP_INT, PROP_NONE);
-	RNA_def_property_int_funcs(prop, "rna_Node_custom3_get_as_int", "rna_Node_custom3_set_as_int", NULL);
 	RNA_def_property_range(prop, 1.0f, 10000.0f);
 	RNA_def_property_ui_text(prop, "X", "");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 
 	prop = RNA_def_property(srna, "size_y", PROP_INT, PROP_NONE);
-	RNA_def_property_int_funcs(prop, "rna_Node_custom4_get_as_int", "rna_Node_custom4_set_as_int", NULL);
 	RNA_def_property_range(prop, 1.0f, 10000.0f);
 	RNA_def_property_ui_text(prop, "Y", "");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");

Modified: trunk/blender/source/blender/nodes/composite/nodes/node_composite_mask.c

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list