Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-10-17 16:55:23 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-10-17 16:55:23 +0400
commitd08b06f773c754c70886901b8964c8093f920a75 (patch)
tree3c600751999c7d827513019f8f5557d3e2c29e58 /intern/cycles/util
parentafb75ad2af0c30f1bc6fd252ca115a59d04e3b85 (diff)
Cycles: motion blur is now curved and passes exactly through the midpoint.
Previously it would only interpolate between the previous and next frame, which meant it might not hit the current frame position.
Diffstat (limited to 'intern/cycles/util')
-rw-r--r--intern/cycles/util/util_transform.cpp3
-rw-r--r--intern/cycles/util/util_transform.h37
2 files changed, 34 insertions, 6 deletions
diff --git a/intern/cycles/util/util_transform.cpp b/intern/cycles/util/util_transform.cpp
index b3c6506dfa0..70ee13d96d7 100644
--- a/intern/cycles/util/util_transform.cpp
+++ b/intern/cycles/util/util_transform.cpp
@@ -246,9 +246,10 @@ static void transform_decompose(Transform *decomp, const Transform *tfm)
decomp->w = make_float4(scale.y.z, scale.z.x, scale.z.y, scale.z.z);
}
-void transform_motion_decompose(MotionTransform *decomp, const MotionTransform *motion)
+void transform_motion_decompose(MotionTransform *decomp, const MotionTransform *motion, const Transform *mid)
{
transform_decompose(&decomp->pre, &motion->pre);
+ transform_decompose(&decomp->mid, mid);
transform_decompose(&decomp->post, &motion->post);
}
diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h
index 3d6aefed56d..df525542207 100644
--- a/intern/cycles/util/util_transform.h
+++ b/intern/cycles/util/util_transform.h
@@ -41,6 +41,7 @@ typedef struct Transform {
typedef struct MotionTransform {
Transform pre;
+ Transform mid;
Transform post;
} MotionTransform;
@@ -383,11 +384,37 @@ __device void transform_motion_interpolate(Transform *tfm, const MotionTransform
{
Transform decomp;
- decomp.x = quat_interpolate(motion->pre.x, motion->post.x, t);
- decomp.y = (1.0f - t)*motion->pre.y + t*motion->post.y;
- decomp.z = (1.0f - t)*motion->pre.z + t*motion->post.z;
- decomp.w = (1.0f - t)*motion->pre.w + t*motion->post.w;
+ /* 3 point bezier curve interpolation for position */
+ float3 Ppre = float4_to_float3(motion->pre.y);
+ float3 Pmid = float4_to_float3(motion->mid.y);
+ float3 Ppost = float4_to_float3(motion->post.y);
+ float3 Pcontrol = 2.0f*Pmid - 0.5f*(Ppre + Ppost);
+ float3 P = Ppre*t*t + Pcontrol*2.0f*t*(1.0f - t) + Ppost*(1.0f - t)*(1.0f - t);
+
+ decomp.y.x = P.x;
+ decomp.y.y = P.y;
+ decomp.y.z = P.z;
+
+ /* linear interpolation for rotation and scale */
+ if(t < 0.5f) {
+ t *= 2.0f;
+
+ decomp.x = quat_interpolate(motion->pre.x, motion->mid.x, t);
+ decomp.y.w = (1.0f - t)*motion->pre.y.w + t*motion->mid.y.w;
+ decomp.z = (1.0f - t)*motion->pre.z + t*motion->mid.z;
+ decomp.w = (1.0f - t)*motion->pre.w + t*motion->mid.w;
+ }
+ else {
+ t = (t - 0.5f)*2.0f;
+
+ decomp.x = quat_interpolate(motion->mid.x, motion->post.x, t);
+ decomp.y.w = (1.0f - t)*motion->mid.y.w + t*motion->post.y.w;
+ decomp.z = (1.0f - t)*motion->mid.z + t*motion->post.z;
+ decomp.w = (1.0f - t)*motion->mid.w + t*motion->post.w;
+ }
+
+ /* compose rotation, translation, scale into matrix */
transform_compose(tfm, &decomp);
}
@@ -398,7 +425,7 @@ __device_inline bool operator==(const MotionTransform& A, const MotionTransform&
return (A.pre == B.pre && A.post == B.post);
}
-void transform_motion_decompose(MotionTransform *decomp, const MotionTransform *motion);
+void transform_motion_decompose(MotionTransform *decomp, const MotionTransform *motion, const Transform *mid);
#endif