title: Finding the length of a ray within a cube
body: <p>I have a ray, going outwards from a camera, I need to find the length of the ray inside the cube. Note that the camera could be inside the cube, in which case it should return the distance to the edge of the cube.</p>
  
  <p>It's for a shader, so it should be relatively small and involve a minimum of branching.</p>
  
  <p>Any ideas?</p>