   namespace device
   {
     __device__ __forceinline__ float
-    getMinTime (const float3& volume_max, const float3& origin, const float3& dir, const float3& cell_size)
+    getMinTime (const float3& volume_max, const float3& origin, const float3& dir, const float3& cell_size, const int3& shift)
     {
-      float txmin = ( (dir.x > 0 ? 0.f : volume_max.x+ SHIFT_X*cell_size.x) - origin.x) / dir.x;
-      float tymin = ( (dir.y > 0 ? 0.f : volume_max.y+ SHIFT_Y*cell_size.y) - origin.y) / dir.y;
-      float tzmin = ( (dir.z > 0 ? 0.f : volume_max.z+ SHIFT_Z*cell_size.z) - origin.z) / dir.z;
+      float txmin = ( (dir.x > 0 ? 0.f : volume_max.x+ shift.x*cell_size.x) - origin.x) / dir.x;
+      float tymin = ( (dir.y > 0 ? 0.f : volume_max.y+ shift.y*cell_size.y) - origin.y) / dir.y;
+      float tzmin = ( (dir.z > 0 ? 0.f : volume_max.z+ shift.z*cell_size.z) - origin.z) / dir.z;
 
       return fmax ( fmax (txmin, tymin), tzmin);
     }
 
     __device__ __forceinline__ float
-    getMaxTime (const float3& volume_max, const float3& origin, const float3& dir, const float3& cell_size)
+    getMaxTime (const float3& volume_max, const float3& origin, const float3& dir, const float3& cell_size, const int3& shift)
     {
-      float txmax = ( (dir.x > 0 ? volume_max.x + SHIFT_X*cell_size.x: 0.f) - origin.x) / dir.x;
-      float tymax = ( (dir.y > 0 ? volume_max.y + SHIFT_Y*cell_size.y: 0.f) - origin.y) / dir.y;
-      float tzmax = ( (dir.z > 0 ? volume_max.z + SHIFT_Z*cell_size.z: 0.f) - origin.z) / dir.z;
+      float txmax = ( (dir.x > 0 ? volume_max.x + shift.x*cell_size.x: 0.f) - origin.x) / dir.x;
+      float tymax = ( (dir.y > 0 ? volume_max.y + shift.y*cell_size.y: 0.f) - origin.y) / dir.y;
+      float tzmax = ( (dir.z > 0 ? volume_max.z + shift.z*cell_size.z: 0.f) - origin.z) / dir.z;
 
       return fmin (fmin (txmax, tymax), tzmax);
     }

      PtrStep<short2> volume;

      Intr intr;

      mutable PtrStep<float> nmap;
      mutable PtrStep<float> vmap;

        ray_dir.z = (ray_dir.z == 0.f) ? 1e-15 : ray_dir.z;

        // computer time when entry and exit volume
        float time_start_volume = getMinTime (volume_size, ray_start, ray_dir, cell_size, shift);
        float time_exit_volume = getMaxTime (volume_size, ray_start, ray_dir, cell_size, shift);

        const float min_dist = 0.f;         //in meters
        time_start_volume = fmax (time_start_volume, min_dist);
