  The interplay between cosmic gas accretion on to galaxies and galaxy mergers
drives the observed morphological diversity of galaxies. By comparing the
state-of-the-art hydrodynamical cosmological simulations Horizon-AGN and
Horizon-noAGN, we unambiguously identify the critical role of active galactic
nuclei (AGN) in setting up the correct galaxy morphology for the massive end of
the population. With AGN feedback, typical kinematic and morpho-metric
properties of galaxy populations as well as the galaxy-halo mass relation are
in much better agreement with observations. Only AGN feedback allows massive
galaxies at the centre of groups and clusters to become ellipticals, while
without AGN feedback those galaxies reform discs. It is the merger-enhanced AGN
activity that is able to freeze the morphological type of the post-merger
remnant by durably quenching its quiescent star formation. Hence morphology is
shown to be driven not only by mass but also by the nature of cosmic accretion:
at constant galaxy mass, ellipticals are galaxies that are mainly assembled
through mergers, while discs are preferentially built from the in situ star
formation fed by smooth cosmic gas infall.
