             pos += elem_step)
         {
             float inv_z = 1.0f / (v_z + Rcurr_inv.data[2].z * z_scaled);
+            if (inv_z < 0)
+                continue;
 
             // project to current cam
             int2 coo =

           pos += elem_step)
      {
        float inv_z = 1.0f / (v_z + Rcurr_inv.data[2].z * z_scaled);

        // project to current cam
        int2 coo =

                            }
                        }
                    }

                    if (integrate)
                    {
