Optical potential from first principles