   const float4 o = mulPost(c_invViewMatrix, make_float4(u, v, -1.0f, 1.0f));
   const float4 d = mulPost(c_invViewMatrix, make_float4(u, v, 1.0f, 1.0f));
 
+  // Dist to far-clipping plane from opengl.
+  const float tfar = norm(perspectiveDivide(d) - perspectiveDivide(o));
+
   Ray ray;
   ray.o = perspectiveDivide(o);
   ray.d = perspectiveDivide(d);
   ray.d = ray.d - ray.o;
   ray.d = normalize(ray.d);
 
-  float tnear = 0.0f;
-  float tfar = 0.0f;
-  const bool hit = intersectBox(ray, probePos - probeSizeHalf, probePos + probeSizeHalf, &tnear, &tfar);
+  float tbnear = 0.0f;
+  float tbfar = 0.0f;
+  const bool hit = intersectBox(ray, probePos - probeSizeHalf, probePos + probeSizeHalf, &tbnear, &tbfar);
   if (!hit)
   {
     d_output[y * texwidth + x] = make_uchar4(0);

    }

    t += dist;
    if (t > tfar)
    {
      break;
    }

    return;
  }

  if (fmodf(tbnear, dist) != 0.0f)
  {
    int tmp = (tbnear / dist);
    tbnear = dist * tmp;
  }

  if (tbnear < 0.0f)
  {
    tbnear = 0.0f;
  }

  if (tbfar > tfar)
  {
    tbfar = tfar;
  }

  // Calc hits with clip sphere.
