   float tmin = fminf(t1, t2);
   float tmax = fmaxf(t1, t2);
 
+  if(t1 < t2)
+  {
+    (*boxNormal).x = 1.f;
+    (*boxNormal).y = 0.f;
+    (*boxNormal).z = 0.f;
+  }
+  else
+  {
+    (*boxNormal).x = -1.f;
+    (*boxNormal).y = 0.f;
+    (*boxNormal).z = 0.f;
+  }
+
   t1 = (boxmin.y - ray.o.y) * invR.y;
   t2 = (boxmax.y - ray.o.y) * invR.y;
   tmin = fmaxf(fminf(t1, t2), tmin);
   tmax = fminf(fmaxf(t1, t2), tmax);
 
+  if(t1 > tmin)
+  {
+    (*boxNormal).x = 0.f;
+    (*boxNormal).y = 1.f;
+    (*boxNormal).z = 0.f;
+  }
+  else if(t2 > tmin)
+  {
+    (*boxNormal).x = 0.f;
+    (*boxNormal).y = -1.f;
+    (*boxNormal).z = 0.f;
+  }
+
   t1 = (boxmin.z - ray.o.z) * invR.z;
   t2 = (boxmax.z - ray.o.z) * invR.z;
   tmin = fmaxf(fminf(t1, t2), tmin);
   tmax = fminf(fmaxf(t1, t2), tmax);
+
+  if(t1 > tmin)
+  {
+    (*boxNormal).x = 0.f;
+    (*boxNormal).y = 0.f;
+    (*boxNormal).z = 1.f;
+  }
+  else if(t2 > tmin)
+  {
+    (*boxNormal).x = 0.f;
+    (*boxNormal).y = 0.f;
+    (*boxNormal).z = -1.f;
+  }
 
   *tnear = tmin;
   *tfar = tmax;

        src = blinnPhong<t_bpc>(src, pos, texCoord, Lpos, V, Ka, Kd, Ks, shininess, constAtt, linearAtt, quadAtt, &sphereNormal);
        justClippedSphere = false;
      }
      else
      {
        src = blinnPhong<t_bpc>(src, pos, texCoord, Lpos, V, Ka, Kd, Ks, shininess, constAtt, linearAtt, quadAtt);
      }
    }
    justClippedPlane = false;
    justClippedSphere = false;


  float tbnear = 0.0f;
  float tbfar = 0.0f;
  float3 boxNormal;
  const bool hit = intersectBox(ray, probePos - probeSizeHalf, probePos + probeSizeHalf, &tbnear, &tbfar, &boxNormal);
  if (!hit)
  {
    d_output[y * texwidth + x] = make_uchar4(0);
