[Bf-blender-cvs] [26687dda5ab] blender-v2.82-release: Fix T71344: Optix render errors with motion blur and unknown bone constraint relationship

Patrick Mours noreply at git.blender.org
Wed Jan 22 15:50:02 CET 2020


Commit: 26687dda5ab7de1e2a00cb6252a6eb919c3f570c
Author: Patrick Mours
Date:   Thu Jan 16 18:08:52 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rB26687dda5ab7de1e2a00cb6252a6eb919c3f570c

Fix T71344: Optix render errors with motion blur and unknown bone constraint relationship

The OptiX SRT motion expects a motion defined by translation,
rotation, shear and scale, but the matrix decomposition code in
Cycles was not able to extract shear information and instead
produced a stretch matrix with the information baked in. This
caused conflicting transforms between traversal and shading
and lead to render artifacts.
This patch changes the matrix decomposition to produce factors
inline with what OptiX expects to fix that.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D6605

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

M	intern/cycles/device/device_optix.cpp
M	intern/cycles/util/util_math_float4.h
M	intern/cycles/util/util_transform.cpp

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

diff --git a/intern/cycles/device/device_optix.cpp b/intern/cycles/device/device_optix.cpp
index a510e538031..8a8eef0e059 100644
--- a/intern/cycles/device/device_optix.cpp
+++ b/intern/cycles/device/device_optix.cpp
@@ -1461,6 +1461,9 @@ class OptiXDevice : public Device {
             srt_data[i].a = decomp[i].z.x;  // scale.x.y
             srt_data[i].b = decomp[i].z.y;  // scale.x.z
             srt_data[i].c = decomp[i].w.x;  // scale.y.z
+            assert(decomp[i].z.z == 0.0f);  // scale.y.x
+            assert(decomp[i].w.y == 0.0f);  // scale.z.x
+            assert(decomp[i].w.z == 0.0f);  // scale.z.y
 
             // Pivot point
             srt_data[i].pvx = 0.0f;
diff --git a/intern/cycles/util/util_math_float4.h b/intern/cycles/util/util_math_float4.h
index bc5322a22bb..cd4b3e3b74c 100644
--- a/intern/cycles/util/util_math_float4.h
+++ b/intern/cycles/util/util_math_float4.h
@@ -179,6 +179,11 @@ ccl_device_inline float4 operator+=(float4 &a, const float4 &b)
   return a = a + b;
 }
 
+ccl_device_inline float4 operator-=(float4 &a, const float4 &b)
+{
+  return a = a - b;
+}
+
 ccl_device_inline float4 operator*=(float4 &a, const float4 &b)
 {
   return a = a * b;
diff --git a/intern/cycles/util/util_transform.cpp b/intern/cycles/util/util_transform.cpp
index 5d64e08b022..302a8a386ac 100644
--- a/intern/cycles/util/util_transform.cpp
+++ b/intern/cycles/util/util_transform.cpp
@@ -227,6 +227,7 @@ static void transform_decompose(DecomposedTransform *decomp, const Transform *tf
   M.y.w = 0.0f;
   M.z.w = 0.0f;
 
+#if 0
   Transform R = M;
   float norm;
   int iteration = 0;
@@ -260,6 +261,41 @@ static void transform_decompose(DecomposedTransform *decomp, const Transform *tf
   decomp->y.w = scale.x.x;
   decomp->z = make_float4(scale.x.y, scale.x.z, scale.y.x, scale.y.y);
   decomp->w = make_float4(scale.y.z, scale.z.x, scale.z.y, scale.z.z);
+#else
+  float3 colx = transform_get_column(&M, 0);
+  float3 coly = transform_get_column(&M, 1);
+  float3 colz = transform_get_column(&M, 2);
+
+  /* extract scale and shear first */
+  float3 scale, shear;
+  scale.x = len(colx);
+  colx /= scale.x;
+  shear.z = dot(colx, coly);
+  coly -= shear.z * colx;
+  scale.y = len(coly);
+  coly /= scale.y;
+  shear.y = dot(colx, colz);
+  colz -= shear.y * colx;
+  shear.x = dot(coly, colz);
+  colz -= shear.x * coly;
+  scale.z = len(colz);
+  colz /= scale.z;
+
+  transform_set_column(&M, 0, colx);
+  transform_set_column(&M, 1, coly);
+  transform_set_column(&M, 2, colz);
+
+  if (transform_negative_scale(M)) {
+    scale *= -1.0f;
+    M = M * transform_scale(-1.0f, -1.0f, -1.0f);
+  }
+
+  decomp->x = transform_to_quat(M);
+
+  decomp->y.w = scale.x;
+  decomp->z = make_float4(shear.z, shear.y, 0.0f, scale.y);
+  decomp->w = make_float4(shear.x, 0.0f, 0.0f, scale.z);
+#endif
 }
 
 void transform_motion_decompose(DecomposedTransform *decomp, const Transform *motion, size_t size)



More information about the Bf-blender-cvs mailing list