Cycles: Fix wrong camera in volume check when domain is only visible to camera rays
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 4 Apr 2016 17:30:38 +0000 (19:30 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 4 Apr 2016 17:30:38 +0000 (19:30 +0200)
intern/cycles/kernel/geom/geom_bvh.h
intern/cycles/kernel/geom/geom_bvh_volume.h
intern/cycles/kernel/geom/geom_bvh_volume_all.h
intern/cycles/kernel/geom/geom_qbvh_volume.h
intern/cycles/kernel/geom/geom_qbvh_volume_all.h
intern/cycles/kernel/kernel_volume.h

index e5cd7b76dedd0c64801afcfa50984daddb1418ae..f480af68c373e59fa81c3ee9374debce94a69bd2 100644 (file)
@@ -299,38 +299,39 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg, const Ra
 #ifdef __VOLUME__
 ccl_device_intersect bool scene_intersect_volume(KernelGlobals *kg,
                                                  const Ray *ray,
-                                                 Intersection *isect)
+                                                 Intersection *isect,
+                                                 const uint visibility)
 {
 #  ifdef __OBJECT_MOTION__
        if(kernel_data.bvh.have_motion) {
 #    ifdef __HAIR__
                if(kernel_data.bvh.have_curves)
-                       return bvh_intersect_volume_hair_motion(kg, ray, isect);
+                       return bvh_intersect_volume_hair_motion(kg, ray, isect, visibility);
 #    endif /* __HAIR__ */
 
-               return bvh_intersect_volume_motion(kg, ray, isect);
+               return bvh_intersect_volume_motion(kg, ray, isect, visibility);
        }
 #  endif /* __OBJECT_MOTION__ */
 
 #  ifdef __HAIR__
        if(kernel_data.bvh.have_curves)
-               return bvh_intersect_volume_hair(kg, ray, isect);
+               return bvh_intersect_volume_hair(kg, ray, isect, visibility);
 #  endif /* __HAIR__ */
 
 #  ifdef __KERNEL_CPU__
 
 #    ifdef __INSTANCING__
        if(kernel_data.bvh.have_instancing)
-               return bvh_intersect_volume_instancing(kg, ray, isect);
+               return bvh_intersect_volume_instancing(kg, ray, isect, visibility);
 #    endif /* __INSTANCING__ */
 
-       return bvh_intersect_volume(kg, ray, isect);
+       return bvh_intersect_volume(kg, ray, isect, visibility);
 #  else /* __KERNEL_CPU__ */
 
 #    ifdef __INSTANCING__
-       return bvh_intersect_volume_instancing(kg, ray, isect);
+       return bvh_intersect_volume_instancing(kg, ray, isect, visibility);
 #    else
-       return bvh_intersect_volume(kg, ray, isect);
+       return bvh_intersect_volume(kg, ray, isect, visibility);
 #    endif /* __INSTANCING__ */
 
 #  endif /* __KERNEL_CPU__ */
@@ -341,30 +342,31 @@ ccl_device_intersect bool scene_intersect_volume(KernelGlobals *kg,
 ccl_device_intersect uint scene_intersect_volume_all(KernelGlobals *kg,
                                                      const Ray *ray,
                                                      Intersection *isect,
-                                                     const uint max_hits)
+                                                     const uint max_hits,
+                                                     const uint visibility)
 {
 #  ifdef __OBJECT_MOTION__
        if(kernel_data.bvh.have_motion) {
 #    ifdef __HAIR__
                if(kernel_data.bvh.have_curves)
-                       return bvh_intersect_volume_all_hair_motion(kg, ray, isect, max_hits);
+                       return bvh_intersect_volume_all_hair_motion(kg, ray, isect, max_hits, visibility);
 #    endif /* __HAIR__ */
 
-               return bvh_intersect_volume_all_motion(kg, ray, isect, max_hits);
+               return bvh_intersect_volume_all_motion(kg, ray, isect, max_hits, visibility);
        }
 #  endif /* __OBJECT_MOTION__ */
 
 #  ifdef __HAIR__
        if(kernel_data.bvh.have_curves)
-               return bvh_intersect_volume_all_hair(kg, ray, isect, max_hits);
+               return bvh_intersect_volume_all_hair(kg, ray, isect, max_hits, visibility);
 #  endif /* __HAIR__ */
 
 #  ifdef __INSTANCING__
        if(kernel_data.bvh.have_instancing)
-               return bvh_intersect_volume_all_instancing(kg, ray, isect, max_hits);
+               return bvh_intersect_volume_all_instancing(kg, ray, isect, max_hits, visibility);
 #  endif /* __INSTANCING__ */
 
-       return bvh_intersect_volume_all(kg, ray, isect, max_hits);
+       return bvh_intersect_volume_all(kg, ray, isect, max_hits, visibility);
 }
 #endif  /* __VOLUME_RECORD_ALL__ */
 
index 937a5d4aaec5fedbd87c3664596b67443c236ee5..14ab6e6891ae865144a929ccd9041cffa04cae66 100644 (file)
@@ -33,7 +33,8 @@
 
 ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                             const Ray *ray,
-                                            Intersection *isect)
+                                            Intersection *isect,
+                                            const uint visibility)
 {
        /* todo:
         * - test if pushing distance on the stack helps (for non shadow rays)
@@ -56,8 +57,6 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
        float3 idir = bvh_inverse_direction(dir);
        int object = OBJECT_NONE;
 
-       const uint visibility = PATH_RAY_ALL_VISIBILITY;
-
 #if BVH_FEATURE(BVH_MOTION)
        Transform ob_itfm;
 #endif
@@ -336,13 +335,15 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 
 ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
                                          const Ray *ray,
-                                         Intersection *isect)
+                                         Intersection *isect,
+                                         const uint visibility)
 {
 #ifdef __QBVH__
        if(kernel_data.bvh.use_qbvh) {
                return BVH_FUNCTION_FULL_NAME(QBVH)(kg,
                                                    ray,
-                                                   isect);
+                                                   isect,
+                                                   visibility);
        }
        else
 #endif
@@ -350,7 +351,8 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg,
                kernel_assert(kernel_data.bvh.use_qbvh == false);
                return BVH_FUNCTION_FULL_NAME(BVH)(kg,
                                                   ray,
-                                                  isect);
+                                                  isect,
+                                                  visibility);
        }
 }
 
index 6b0b20138da4ce370899924bc69128748ae19d42..b16eb3906e89956b0a296efb44a0932c45e2368b 100644 (file)
@@ -34,7 +34,8 @@
 ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                             const Ray *ray,
                                             Intersection *isect_array,
-                                            const uint max_hits)
+                                            const uint max_hits,
+                                            const uint visibility)
 {
        /* todo:
         * - test if pushing distance on the stack helps (for non shadow rays)
@@ -59,8 +60,6 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
        int object = OBJECT_NONE;
        float isect_t = tmax;
 
-       const uint visibility = PATH_RAY_ALL_VISIBILITY;
-
 #if BVH_FEATURE(BVH_MOTION)
        Transform ob_itfm;
 #endif
@@ -430,14 +429,16 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 ccl_device_inline uint BVH_FUNCTION_NAME(KernelGlobals *kg,
                                          const Ray *ray,
                                          Intersection *isect_array,
-                                         const uint max_hits)
+                                         const uint max_hits,
+                                         const uint visibility)
 {
 #ifdef __QBVH__
        if(kernel_data.bvh.use_qbvh) {
                return BVH_FUNCTION_FULL_NAME(QBVH)(kg,
                                                    ray,
                                                    isect_array,
-                                                   max_hits);
+                                                   max_hits,
+                                                   visibility);
        }
        else
 #endif
@@ -446,7 +447,8 @@ ccl_device_inline uint BVH_FUNCTION_NAME(KernelGlobals *kg,
                return BVH_FUNCTION_FULL_NAME(BVH)(kg,
                                                   ray,
                                                   isect_array,
-                                                  max_hits);
+                                                  max_hits,
+                                                  visibility);
        }
 }
 
index 696a48a7b3ea9b23a0e28f7df4a0a5b793c06f3e..36648fdd2445ec36c10cb5d49b2b2289df7f23b4 100644 (file)
@@ -29,7 +29,8 @@
 
 ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                              const Ray *ray,
-                                             Intersection *isect)
+                                             Intersection *isect,
+                                             const uint visibility)
 {
        /* TODO(sergey):
         * - Test if pushing distance on the stack helps.
@@ -51,8 +52,6 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
        float3 idir = bvh_inverse_direction(dir);
        int object = OBJECT_NONE;
 
-       const uint visibility = PATH_RAY_ALL_VISIBILITY;
-
 #if BVH_FEATURE(BVH_MOTION)
        Transform ob_itfm;
 #endif
index 2cef0dcb1dc38d46ebdaf28919cd2e88bfd9bba1..2cf78f2f00e189947ad039db7a14fba3f92f1048 100644 (file)
@@ -30,7 +30,8 @@
 ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                              const Ray *ray,
                                              Intersection *isect_array,
-                                             const uint max_hits)
+                                             const uint max_hits,
+                                             const uint visibility)
 {
        /* TODO(sergey):
         * - Test if pushing distance on the stack helps.
@@ -54,8 +55,6 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
        int object = OBJECT_NONE;
        float isect_t = tmax;
 
-       const uint visibility = PATH_RAY_ALL_VISIBILITY;
-
 #if BVH_FEATURE(BVH_MOTION)
        Transform ob_itfm;
 #endif
index 1dc2c5f8fbbfa9232e15aa1bc7ebf80447adb6cf..86a3adbf93af26d9b9190766a7cf0768d3359c59 100644 (file)
@@ -994,12 +994,14 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
 
        int stack_index = 0, enclosed_index = 0;
 
+       const uint visibility = PATH_RAY_ALL_VISIBILITY | kernel_data.integrator.layer_flag;
 #ifdef __VOLUME_RECORD_ALL__
        Intersection hits[2*VOLUME_STACK_SIZE];
        uint num_hits = scene_intersect_volume_all(kg,
                                                   &volume_ray,
                                                   hits,
-                                                  2*VOLUME_STACK_SIZE);
+                                                  2*VOLUME_STACK_SIZE,
+                                                  visibility);
        if(num_hits > 0) {
                int enclosed_volumes[VOLUME_STACK_SIZE];
                Intersection *isect = hits;
@@ -1048,7 +1050,7 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
              step < 2 * VOLUME_STACK_SIZE)
        {
                Intersection isect;
-               if(!scene_intersect_volume(kg, &volume_ray, &isect)) {
+               if(!scene_intersect_volume(kg, &volume_ray, &isect, visibility)) {
                        break;
                }
 
@@ -1159,7 +1161,8 @@ ccl_device void kernel_volume_stack_update_for_subsurface(KernelGlobals *kg,
        uint num_hits = scene_intersect_volume_all(kg,
                                                   &volume_ray,
                                                   hits,
-                                                  2*VOLUME_STACK_SIZE);
+                                                  2*VOLUME_STACK_SIZE,
+                                                  PATH_RAY_ALL_VISIBILITY);
        if(num_hits > 0) {
                Intersection *isect = hits;
 
@@ -1175,7 +1178,10 @@ ccl_device void kernel_volume_stack_update_for_subsurface(KernelGlobals *kg,
        Intersection isect;
        int step = 0;
        while(step < 2 * VOLUME_STACK_SIZE &&
-             scene_intersect_volume(kg, &volume_ray, &isect))
+             scene_intersect_volume(kg,
+                                    &volume_ray,
+                                    &isect,
+                                    PATH_RAY_ALL_VISIBILITY))
        {
                ShaderData sd;
                shader_setup_from_ray(kg, &sd, &isect, &volume_ray);