1. A computer-implemented method, comprising: performing, by a computer: receiving an image, wherein the image comprises a two-dimensional representation of a three-dimensional object; determining characteristics of one or more light sources affecting the image; generating a three-dimensional mesh approximating a shape of the three-dimensional object, wherein the three-dimensional mesh comprises a plurality of connected polygons, and wherein the three-dimensional mesh is generated based on a first downsampled version of the image; rendering a candidate image based on the three-dimensional mesh and the characteristics of the one or more light sources; and outputting the three-dimensional mesh if a difference between the image and the candidate image is smaller than a threshold error value.