[Bf-blender-cvs] [6997908] master: Cycles: add per object options to disable motion blur and set deformation motion steps.

Brecht Van Lommel noreply at git.blender.org
Sat Mar 29 15:33:05 CET 2014


Commit: 6997908afc38a3c98d09939f3b46f10d7a165d2e
Author: Brecht Van Lommel
Date:   Sat Mar 29 13:03:47 2014 +0100
https://developer.blender.org/rB6997908afc38a3c98d09939f3b46f10d7a165d2e

Cycles: add per object options to disable motion blur and set deformation motion steps.

Notes:

* The motion steps only affect deformation motion blur.
* The actual number of steps is 2^(steps - 1). This avoids having to sample at
  many different times for object with more/fewer steps, now the times overlap.
* Deformation motion blur is enabled by default in existing files that have
  motion blur enabled. If the object is not deforming, this will be detected at
  export time, so raytracing performance will not be affected.

Part of the code is from the summer of code project by Gavin Howard.

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

M	intern/cycles/blender/addon/properties.py
M	intern/cycles/blender/addon/ui.py
M	intern/cycles/blender/blender_object.cpp
M	intern/cycles/blender/blender_util.h

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

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 1d56824..eb6680b 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -742,6 +742,41 @@ class CyclesMeshSettings(bpy.types.PropertyGroup):
         del bpy.types.MetaBall.cycles
 
 
+class CyclesObjectBlurSettings(bpy.types.PropertyGroup):
+
+    @classmethod
+    def register(cls):
+        
+        bpy.types.Object.cycles = PointerProperty(
+                name="Cycles Object Settings",
+                description="Cycles object settings",
+                type=cls,
+                )
+
+        cls.use_motion_blur = BoolProperty(
+                name="Use Motion Blur",
+                description="Use motion blur for this object",
+                default=True,
+                )
+
+        cls.use_deform_motion = BoolProperty(
+                name="Use Deformation Motion",
+                description="Use deformation motion blur for this object",
+                default=True,
+                )
+
+        cls.motion_steps = IntProperty(
+                name="Motion Steps",
+                description="Control accuracy of deformation motion blur, more steps gives more memory usage (actual number of steps is 2^(steps - 1))",
+                min=1, soft_max=8,
+                default=1,
+                )
+
+    @classmethod
+    def unregister(cls):
+        del bpy.types.Object.cycles
+
+
 class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
     @classmethod
     def register(cls):
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 70368c2..60d1b03 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -572,6 +572,50 @@ class Cycles_PT_mesh_normals(CyclesButtonsPanel, Panel):
         col.label()
 
 
+class CyclesObject_PT_motion_blur(CyclesButtonsPanel, Panel):
+    bl_label = "Motion Blur"
+    bl_context = "object"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        ob = context.object
+        return CyclesButtonsPanel.poll(context) and ob and ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META'}
+        
+    def draw_header(self, context):
+        layout = self.layout
+
+        rd = context.scene.render
+        scene = context.scene
+        cscene = scene.cycles
+
+        layout.active = (rd.use_motion_blur and cscene.device == 'CPU')
+
+        ob = context.object
+        cob = ob.cycles
+
+        layout.prop(cob, "use_motion_blur", text="")
+
+    def draw(self, context):
+        layout = self.layout
+
+        rd = context.scene.render
+        scene = context.scene
+        cscene = scene.cycles
+
+        ob = context.object
+        cob = ob.cycles
+
+        layout.active = (rd.use_motion_blur and cscene.device == 'CPU' and cob.use_motion_blur)
+
+        row = layout.row()
+        row.prop(cob, "use_deform_motion", text="Deformation")
+
+        sub = row.row()
+        sub.active = cob.use_deform_motion
+        sub.prop(cob, "motion_steps", text="Steps")
+
+
 class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
     bl_label = "Ray Visibility"
     bl_context = "object"
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index bd4becb..6922559 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -244,7 +244,7 @@ Object *BlenderSync::sync_object(BL::Object b_parent, int persistent_id[OBJECT_P
 	if(motion) {
 		object = object_map.find(key);
 
-		if(object) {
+		if(object && (scene->need_motion() == Scene::MOTION_PASS || object_use_motion(b_ob))) {
 			/* object transformation */
 			if(tfm != object->tfm) {
 				if(motion_time == -1.0f) {
@@ -323,9 +323,11 @@ Object *BlenderSync::sync_object(BL::Object b_parent, int persistent_id[OBJECT_P
 		if(scene->need_motion() == Scene::MOTION_BLUR && object->mesh) {
 			Mesh *mesh = object->mesh;
 
-			if(true) {
-				if(true) {
-					mesh->motion_steps = 3;
+			mesh->use_motion_blur = false;
+
+			if(object_use_motion(b_ob)) {
+				if(object_use_deform_motion(b_ob)) {
+					mesh->motion_steps = object_motion_steps(b_ob);
 					mesh->use_motion_blur = true;
 				}
 
diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h
index 58e523d..bea5ee4 100644
--- a/intern/cycles/blender/blender_util.h
+++ b/intern/cycles/blender/blender_util.h
@@ -341,6 +341,36 @@ static inline void mesh_texture_space(BL::Mesh b_mesh, float3& loc, float3& size
 	loc = loc*size - make_float3(0.5f, 0.5f, 0.5f);
 }
 
+/* object used for motion blur */
+static inline bool object_use_motion(BL::Object b_ob)
+{
+	PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
+	bool use_motion = get_boolean(cobject, "use_motion_blur");
+	
+	return use_motion;
+}
+
+/* object motion steps */
+static inline uint object_motion_steps(BL::Object b_ob)
+{
+	PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
+	uint steps = get_int(cobject, "motion_steps");
+
+	/* use uneven number of steps so we get one keyframe at the current frame,
+	 * and ue 2^(steps - 1) so objects with more/fewer steps still have samples
+	 * at the same times, to avoid sampling at many different times */
+	return (2 << (steps - 1)) + 1;
+}
+
+/* object uses deformation motion blur */
+static inline bool object_use_deform_motion(BL::Object b_ob)
+{
+	PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
+	bool use_deform_motion = get_boolean(cobject, "use_deform_motion");
+	
+	return use_deform_motion;
+}
+
 /* ID Map
  *
  * Utility class to keep in sync with blender data.




More information about the Bf-blender-cvs mailing list