[Bf-blender-cvs] [ff1244dac72] soc-2019-cycles-procedural: Fixed CUDA and OpenCL kernels for reflect and project functions.

OmarSquircleArt noreply at git.blender.org
Fri May 31 21:23:33 CEST 2019


Commit: ff1244dac720441123b9776458395545d6ce603f
Author: OmarSquircleArt
Date:   Fri May 31 21:24:16 2019 +0200
Branches: soc-2019-cycles-procedural
https://developer.blender.org/rBff1244dac720441123b9776458395545d6ce603f

Fixed CUDA and OpenCL kernels for reflect and project functions.

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

M	intern/cycles/kernel/svm/svm_math_util.h
M	intern/cycles/util/util_math_float3.h

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

diff --git a/intern/cycles/kernel/svm/svm_math_util.h b/intern/cycles/kernel/svm/svm_math_util.h
index 3d8c16a8495..cc505e1791e 100644
--- a/intern/cycles/kernel/svm/svm_math_util.h
+++ b/intern/cycles/kernel/svm/svm_math_util.h
@@ -33,7 +33,9 @@ ccl_device void svm_vector_math(
       *Fac = 0.0f;
       break;
     case NODE_VECTOR_MATH_DIVIDE:
-      *Vector = safe_divide(Vector1, Vector2);
+      *Vector = make_float3(safe_divide(Vector1.x, Vector2.x),
+                            safe_divide(Vector1.y, Vector2.y),
+                            safe_divide(Vector1.z, Vector2.z));
       *Fac = 0.0f;
       break;
     case NODE_VECTOR_MATH_CROSS_PRODUCT:
diff --git a/intern/cycles/util/util_math_float3.h b/intern/cycles/util/util_math_float3.h
index ee8a28a5ccf..7d3f184f9b4 100644
--- a/intern/cycles/util/util_math_float3.h
+++ b/intern/cycles/util/util_math_float3.h
@@ -50,9 +50,6 @@ ccl_device_inline bool operator!=(const float3 &a, const float3 &b);
 ccl_device_inline float dot(const float3 &a, const float3 &b);
 ccl_device_inline float dot_xy(const float3 &a, const float3 &b);
 ccl_device_inline float3 cross(const float3 &a, const float3 &b);
-ccl_device_inline float3 safe_divide(const float3 &a, const float3 &b);
-ccl_device_inline float3 project(const float3 &v, const float3 &v_proj);
-ccl_device_inline float3 reflect(const float3 &i, const float3 &n);
 ccl_device_inline float3 normalize(const float3 &a);
 ccl_device_inline float3 min(const float3 &a, const float3 &b);
 ccl_device_inline float3 max(const float3 &a, const float3 &b);
@@ -68,6 +65,9 @@ ccl_device_inline float max3(float3 a);
 ccl_device_inline float len(const float3 a);
 ccl_device_inline float len_squared(const float3 a);
 
+ccl_device_inline float3 reflect(const float3 i, const float3 n);
+ccl_device_inline float3 project(const float3 v, const float3 v_proj);
+
 ccl_device_inline float3 saturate3(float3 a);
 ccl_device_inline float3 safe_normalize(const float3 a);
 ccl_device_inline float3 normalize_len(const float3 a, float *t);
@@ -216,25 +216,6 @@ ccl_device_inline float dot(const float3 &a, const float3 &b)
 #  endif
 }
 
-ccl_device_inline float3 safe_divide(const float3 &a, const float3 &b)
-{
-  return make_float3((b.x != 0.0f) ? a.x / b.x : 0.0f,
-                     (b.y != 0.0f) ? a.y / b.y : 0.0f,
-                     (b.z != 0.0f) ? a.z / b.z : 0.0f);
-}
-
-ccl_device_inline float3 project(const float3 &v, const float3 &v_proj)
-{
-  float lenSquared = dot(v_proj, v_proj);
-  return (lenSquared != 0.0f) ? (dot(v, v_proj) / lenSquared) * v_proj : make_float3(0.0f);
-}
-
-ccl_device_inline float3 reflect(const float3 &i, const float3 &n)
-{
-  float3 normal = normalize(n);
-  return i - 2 * normal * dot(i, normal);
-}
-
 ccl_device_inline float dot_xy(const float3 &a, const float3 &b)
 {
 #  if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__)
@@ -342,6 +323,19 @@ ccl_device_inline float len_squared(const float3 a)
   return dot(a, a);
 }
 
+ccl_device_inline float3 reflect(const float3 i, const float3 n)
+{
+  float3 normal = normalize(n);
+  return i - 2 * normal * dot(i, normal);
+}
+
+ccl_device_inline float3 project(const float3 v, const float3 v_proj)
+{
+  float lenSquared = dot(v_proj, v_proj);
+  return (lenSquared != 0.0f) ? (dot(v, v_proj) / lenSquared) * v_proj :
+                                make_float3(0.0f, 0.0f, 0.0f);
+}
+
 ccl_device_inline float3 saturate3(float3 a)
 {
   return make_float3(saturate(a.x), saturate(a.y), saturate(a.z));



More information about the Bf-blender-cvs mailing list