Wavefront Engineering for Freeform Optics