Optimal control with discontinuous running cost: eikonal equation and shape from shading