We demonstrate that the phase contrast observed with an amplitude modulation atomic force microscope depends on two factors, the generation of higher harmonics components and the energy dissipated on the sample surface. Those factors are ultimately related to the chemical composition and structure of the surface. Our findings are general, but they specifically describe the results obtained while imaging soft materials in liquid. Molecular resolution experiments performed on a protein membrane surface in liquid confirm the theory.