diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-10-08 18:30:51 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-10-09 13:58:03 +0300 |
commit | 8fa4fccec42ac98cfbc2652c8016d80c336564c4 (patch) | |
tree | e3b702934f781fdc864e0f8b65e2e998a1023b8f | |
parent | c8005703f2989fe00901c630c009a5080c87e90b (diff) |
Cycles: Fix intersection issues caused by degenerate instance matrix
Issue was caused by wrong intersection distance scaling on instance pop,
which could cause intersection distance to become zero, confusing following
intersection checks.
-rw-r--r-- | intern/cycles/kernel/geom/geom_bvh_volume_all.h | 12 | ||||
-rw-r--r-- | intern/cycles/kernel/geom/geom_object.h | 8 | ||||
-rw-r--r-- | intern/cycles/kernel/geom/geom_qbvh_volume_all.h | 12 |
3 files changed, 16 insertions, 16 deletions
diff --git a/intern/cycles/kernel/geom/geom_bvh_volume_all.h b/intern/cycles/kernel/geom/geom_bvh_volume_all.h index b6db36f4b17..5bb7a67f10b 100644 --- a/intern/cycles/kernel/geom/geom_bvh_volume_all.h +++ b/intern/cycles/kernel/geom/geom_bvh_volume_all.h @@ -232,8 +232,8 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, #if BVH_FEATURE(BVH_MOTION) float t_fac = len(transform_direction(&ob_tfm, 1.0f/idir)); #else - Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM); - float t_fac = len(transform_direction(&tfm, 1.0f/idir)); + Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM); + float t_fac = 1.0f / len(transform_direction(&itfm, dir)); #endif for(int i = 0; i < num_hits_in_instance; i++) { (isect_array-i-1)->t *= t_fac; @@ -270,8 +270,8 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, # if BVH_FEATURE(BVH_MOTION) float t_fac = len(transform_direction(&ob_tfm, 1.0f/idir)); # else - Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM); - float t_fac = len(transform_direction(&tfm, 1.0f/idir)); + Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM); + float t_fac = 1.0f / len(transform_direction(&itfm, dir)); #endif for(int i = 0; i < num_hits_in_instance; i++) { (isect_array-i-1)->t *= t_fac; @@ -313,8 +313,8 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, # if BVH_FEATURE(BVH_MOTION) float t_fac = len(transform_direction(&ob_tfm, 1.0f/idir)); # else - Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM); - float t_fac = len(transform_direction(&tfm, 1.0f/idir)); + Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM); + float t_fac = 1.0f / len(transform_direction(&itfm, dir)); #endif for(int i = 0; i < num_hits_in_instance; i++) { (isect_array-i-1)->t *= t_fac; diff --git a/intern/cycles/kernel/geom/geom_object.h b/intern/cycles/kernel/geom/geom_object.h index 9d0a008fff1..bf1a3eb2413 100644 --- a/intern/cycles/kernel/geom/geom_object.h +++ b/intern/cycles/kernel/geom/geom_object.h @@ -428,8 +428,8 @@ ccl_device_inline void qbvh_instance_push(KernelGlobals *kg, ccl_device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, ccl_addr_space float *t) { if(*t != FLT_MAX) { - Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM); - *t *= len(transform_direction(&tfm, 1.0f/(*idir))); + Transform tfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM); + *t /= len(transform_direction(&tfm, ray->D)); } *P = ray->P; @@ -441,8 +441,8 @@ ccl_device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray ccl_device_inline void bvh_instance_pop_factor(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t_fac) { - Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM); - *t_fac = len(transform_direction(&tfm, 1.0f/(*idir))); + Transform tfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM); + *t_fac = 1.0f / len(transform_direction(&tfm, ray->D)); *P = ray->P; *dir = bvh_clamp_direction(ray->D); diff --git a/intern/cycles/kernel/geom/geom_qbvh_volume_all.h b/intern/cycles/kernel/geom/geom_qbvh_volume_all.h index 056ca9a1ad9..2baf23d6bd6 100644 --- a/intern/cycles/kernel/geom/geom_qbvh_volume_all.h +++ b/intern/cycles/kernel/geom/geom_qbvh_volume_all.h @@ -249,8 +249,8 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, #if BVH_FEATURE(BVH_MOTION) float t_fac = len(transform_direction(&ob_tfm, 1.0f/idir)); #else - Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM); - float t_fac = len(transform_direction(&tfm, 1.0f/idir)); + Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM); + float t_fac = 1.0f / len(transform_direction(&itfm, dir)); #endif for(int i = 0; i < num_hits_in_instance; i++) { (isect_array-i-1)->t *= t_fac; @@ -287,8 +287,8 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, # if BVH_FEATURE(BVH_MOTION) float t_fac = len(transform_direction(&ob_tfm, 1.0f/idir)); # else - Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM); - float t_fac = len(transform_direction(&tfm, 1.0f/idir)); + Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM); + float t_fac = 1.0f / len(transform_direction(&itfm, dir)); #endif for(int i = 0; i < num_hits_in_instance; i++) { (isect_array-i-1)->t *= t_fac; @@ -330,8 +330,8 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, # if BVH_FEATURE(BVH_MOTION) float t_fac = len(transform_direction(&ob_tfm, 1.0f/idir)); # else - Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM); - float t_fac = len(transform_direction(&tfm, 1.0f/idir)); + Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM); + float t_fac = 1.0f / len(transform_direction(&itfm, dir)); #endif for(int i = 0; i < num_hits_in_instance; i++) { (isect_array-i-1)->t *= t_fac; |