We describe a technique for improving the accuracy of range maps measured by a time-of-flight (TOF) camera, a novel type of sensor that provides a range map registered perfectly with an intensity image. Our technique is based on the observation that the range map and intensity image measured by a TOF camera are not independent but are linked by the shading constraint: If the reflectance properties of the surface are known, a certain range map implies a corresponding intensity image. In practice, a general reflectance model (such as Lambertian reflectance) provides a sufficient approximation for a wide range of surfaces. We impose the shading constraint using a probabilistic model of image formation and find a maximum a posteriori estimate for the true range map. We present results on both synthetic and real TOF camera images that demonstrate the robust shape estimates achieved by the algorithm. We also show how the reflectivity (or albedo) of the surface can be estimated, both globally for an entire object and locally for objects where albedo varies across the surface.