In contrast to the directivity, the gain G of an antenna considers additionally the efficiency η of the antenna (not the radiated power density is compared to the isotropic radiator but the power fed to the antenna). So, losses in the antenna are included in the value of the gain – but not in the value of the directivity:

(1) G = η D