[Bf-blender-cvs] [848ecf4ee3e] cycles_embree: Cycles: Matched motion interpolation to Embree's interpolation

Stefan Werner noreply at git.blender.org
Sun Nov 26 23:11:41 CET 2017


Commit: 848ecf4ee3e33b8852fc9f82357edc155af1c5be
Author: Stefan Werner
Date:   Tue Nov 14 23:17:41 2017 +0100
Branches: cycles_embree
https://developer.blender.org/rB848ecf4ee3e33b8852fc9f82357edc155af1c5be

Cycles: Matched motion interpolation to Embree's interpolation

When Embree is turned on, the transform matrices of motion steps are now interpolated linearly (the wrong way). Cycles itself has a better way of interpolating, but when mixing it with Embree's direct matrix interpolation, it results in artefacts.

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

M	intern/cycles/kernel/geom/geom_object.h
M	intern/cycles/util/util_transform.h

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

diff --git a/intern/cycles/kernel/geom/geom_object.h b/intern/cycles/kernel/geom/geom_object.h
index a276096a745..815be6dcb9a 100644
--- a/intern/cycles/kernel/geom/geom_object.h
+++ b/intern/cycles/kernel/geom/geom_object.h
@@ -105,6 +105,12 @@ ccl_device_inline Transform object_fetch_transform_motion(KernelGlobals *kg, int
 	motion.post_y = kernel_tex_fetch(__objects, offset + 7);
 
 	Transform tfm;
+#ifdef __EMBREE__
+	if(kernel_data.bvh.scene) {
+		transform_motion_interpolate_straight(&tfm, &motion, time);
+	}
+	else
+#endif
 	transform_motion_interpolate(&tfm, &motion, time);
 
 	return tfm;
diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h
index aef168ca64d..bb2c74842cf 100644
--- a/intern/cycles/util/util_transform.h
+++ b/intern/cycles/util/util_transform.h
@@ -516,6 +516,46 @@ ccl_device void transform_motion_interpolate(Transform *tfm, const DecompMotionT
 	transform_compose(tfm, &decomp);
 }
 
+ccl_device void transform_motion_interpolate_straight(Transform *tfm, const DecompMotionTransform *motion, float t)
+{
+	Transform decomp;
+	Transform step1, step2;
+
+	decomp.x = motion->mid.x;
+	decomp.y = motion->mid.y;
+	decomp.z = motion->mid.z;
+	decomp.w = motion->mid.w;
+
+	/* linear interpolation for rotation and scale */
+	if(t < 0.5f) {
+		t *= 2.0f;
+
+		transform_compose(&step2, &decomp);
+
+		decomp.x = motion->pre_x;
+		decomp.y = motion->pre_y;
+
+		transform_compose(&step1, &decomp);
+	}
+	else {
+		t = (t - 0.5f)*2.0f;
+
+		transform_compose(&step1, &decomp);
+
+		decomp.x = motion->post_x;
+		decomp.y = motion->post_y;
+
+		transform_compose(&step2, &decomp);
+	}
+
+	/* matrix lerp */
+	tfm->x = (1.0f - t) * step1.x + t * step2.x;
+	tfm->y = (1.0f - t) * step1.y + t * step2.y;
+	tfm->z = (1.0f - t) * step1.z + t * step2.z;
+	tfm->w = (1.0f - t) * step1.w + t * step2.w;
+
+}
+
 #ifndef __KERNEL_GPU__
 
 class BoundBox2D;



More information about the Bf-blender-cvs mailing list