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:
authorStefan Werner <stefan.werner@tangent-animation.com>2020-02-18 01:44:12 +0300
committerStefan Werner <stefan.werner@tangent-animation.com>2020-02-18 01:44:12 +0300
commitf5740ec8cfc097c4cdf213e0295892094cd6c80c (patch)
tree1ac10d859cb994cb997e8b7ce953a1c747989aac
parent435476cb87404ac2252641cf5fd50a816836083d (diff)
Cycles: Enabled quaternion motion blur with Embree.
Bringing Embree's motion blur closer to Cycles' native blur. This requries Embree 3.8.0 or newer. Differential Revision: https://developer.blender.org/D6575
-rw-r--r--build_files/cmake/platform/platform_apple.cmake2
-rw-r--r--build_files/cmake/platform/platform_unix.cmake2
-rw-r--r--intern/cycles/bvh/bvh_embree.cpp15
-rw-r--r--intern/cycles/cmake/external_libs.cmake2
-rw-r--r--intern/cycles/kernel/geom/geom_object.h8
-rw-r--r--intern/cycles/util/util_transform.h31
6 files changed, 21 insertions, 39 deletions
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index b231a2b6fa4..e997f105324 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -381,7 +381,7 @@ if(WITH_CYCLES_OSL)
endif()
if(WITH_CYCLES_EMBREE)
- find_package(Embree 3.2.4 REQUIRED)
+ find_package(Embree 3.8.0 REQUIRED)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Xlinker -stack_size -Xlinker 0x100000")
endif()
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index 91f836d5265..ac570f17e47 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -393,7 +393,7 @@ if(WITH_OPENCOLORIO)
endif()
if(WITH_CYCLES_EMBREE)
- find_package(Embree 3.2.4 REQUIRED)
+ find_package(Embree 3.8.0 REQUIRED)
endif()
if(WITH_OPENIMAGEDENOISE)
diff --git a/intern/cycles/bvh/bvh_embree.cpp b/intern/cycles/bvh/bvh_embree.cpp
index 851fdad7842..35c1b463b49 100644
--- a/intern/cycles/bvh/bvh_embree.cpp
+++ b/intern/cycles/bvh/bvh_embree.cpp
@@ -563,9 +563,20 @@ void BVHEmbree::add_instance(Object *ob, int i)
rtcSetGeometryTimeStepCount(geom_id, num_motion_steps);
if (ob->use_motion()) {
+ array<DecomposedTransform> decomp(ob->motion.size());
+ transform_motion_decompose(decomp.data(), ob->motion.data(), ob->motion.size());
for (size_t step = 0; step < num_motion_steps; ++step) {
- rtcSetGeometryTransform(
- geom_id, step, RTC_FORMAT_FLOAT3X4_ROW_MAJOR, (const float *)&ob->motion[step]);
+ RTCQuaternionDecomposition rtc_decomp;
+ rtcInitQuaternionDecomposition(&rtc_decomp);
+ rtcQuaternionDecompositionSetQuaternion(
+ &rtc_decomp, decomp[step].x.w, decomp[step].x.x, decomp[step].x.y, decomp[step].x.z);
+ rtcQuaternionDecompositionSetScale(
+ &rtc_decomp, decomp[step].y.w, decomp[step].z.w, decomp[step].w.w);
+ rtcQuaternionDecompositionSetTranslation(
+ &rtc_decomp, decomp[step].y.x, decomp[step].y.y, decomp[step].y.z);
+ rtcQuaternionDecompositionSetSkew(
+ &rtc_decomp, decomp[step].z.x, decomp[step].z.y, decomp[step].w.x);
+ rtcSetGeometryTransformQuaternion(geom_id, step, &rtc_decomp);
}
}
else {
diff --git a/intern/cycles/cmake/external_libs.cmake b/intern/cycles/cmake/external_libs.cmake
index 5bf681792ca..0b082b11cf7 100644
--- a/intern/cycles/cmake/external_libs.cmake
+++ b/intern/cycles/cmake/external_libs.cmake
@@ -135,7 +135,7 @@ if(CYCLES_STANDALONE_REPOSITORY)
####
# embree
if(WITH_CYCLES_EMBREE)
- find_package(embree 3.2.4 REQUIRED)
+ find_package(embree 3.8.0 REQUIRED)
endif()
####
diff --git a/intern/cycles/kernel/geom/geom_object.h b/intern/cycles/kernel/geom/geom_object.h
index af4e6fbd89b..ac2ddf575ca 100644
--- a/intern/cycles/kernel/geom/geom_object.h
+++ b/intern/cycles/kernel/geom/geom_object.h
@@ -81,13 +81,7 @@ ccl_device_inline Transform object_fetch_transform_motion(KernelGlobals *kg,
const uint num_steps = kernel_tex_fetch(__objects, object).numsteps * 2 + 1;
Transform tfm;
-# ifdef __EMBREE__
- if (kernel_data.bvh.scene) {
- transform_motion_array_interpolate_straight(&tfm, motion, num_steps, time);
- }
- else
-# endif
- transform_motion_array_interpolate(&tfm, motion, num_steps, time);
+ transform_motion_array_interpolate(&tfm, motion, num_steps, time);
return tfm;
}
diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h
index 407654245cb..d0a6264d5cf 100644
--- a/intern/cycles/util/util_transform.h
+++ b/intern/cycles/util/util_transform.h
@@ -344,10 +344,10 @@ ccl_device_inline Transform transform_empty()
ccl_device_inline float4 quat_interpolate(float4 q1, float4 q2, float t)
{
- /* use simpe nlerp instead of slerp. it's faster and almost the same */
+ /* Optix is using lerp to interpolate motion transformations. */
+#ifdef __KERNEL_OPTIX__
return normalize((1.0f - t) * q1 + t * q2);
-
-#if 0
+#else /* __KERNEL_OPTIX__ */
/* note: this does not ensure rotation around shortest angle, q1 and q2
* are assumed to be matched already in transform_motion_decompose */
float costheta = dot(q1, q2);
@@ -365,7 +365,7 @@ ccl_device_inline float4 quat_interpolate(float4 q1, float4 q2, float t)
float thetap = theta * t;
return q1 * cosf(thetap) + qperp * sinf(thetap);
}
-#endif
+#endif /* __KERNEL_OPTIX__ */
}
ccl_device_inline Transform transform_quick_inverse(Transform M)
@@ -468,29 +468,6 @@ ccl_device void transform_motion_array_interpolate(Transform *tfm,
#ifndef __KERNEL_GPU__
-# ifdef WITH_EMBREE
-ccl_device void transform_motion_array_interpolate_straight(
- Transform *tfm, const ccl_global DecomposedTransform *motion, uint numsteps, float time)
-{
- /* Figure out which steps we need to interpolate. */
- int maxstep = numsteps - 1;
- int step = min((int)(time * maxstep), maxstep - 1);
- float t = time * maxstep - step;
-
- const ccl_global DecomposedTransform *a = motion + step;
- const ccl_global DecomposedTransform *b = motion + step + 1;
- Transform step1, step2;
-
- transform_compose(&step1, a);
- transform_compose(&step2, b);
-
- /* 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;
-}
-# endif
-
class BoundBox2D;
ccl_device_inline bool operator==(const DecomposedTransform &A, const DecomposedTransform &B)