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
This commit is contained in:
parent
435476cb87
commit
f5740ec8cf
|
@ -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()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
|
||||
####
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue