  We reproduce the blue and red sequences in the observed joint distribution of
colour and magnitude for galaxies at low and high redshifts using hybrid
N-body/semi-analytic simulations of galaxy formation. The match of model and
data is achieved by mimicking the effects of cold flows versus shock heating
coupled to feedback from active galactic nuclei (AGNs), as predicted by Dekel &
Birnboim (2006). After a critical epoch z=3, only haloes below a critical
shock-heating mass 10^12MSun enjoy gas supply by cold flows and form stars,
while cooling and star formation are shut down abruptly above this mass. The
shock-heated gas is kept hot because being dilute it is vulnerable to feedback
from energetic sources such as AGNs in their self-regulated mode. The shutdown
explains in detail the bright-end truncation of the blue sequence at ~L*, the
appearance of luminous red-and-dead galaxies on the red sequence starting
already at z~2, the colour bimodality, its strong dependence on environment
density and its correlations with morphology and other galaxy properties.
Before z~2-3, even haloes above the shock-heating mass form stars by cold
streams penetrating through the hot gas. This explains the bright star-forming
galaxies at z~3-4, the early appearance of massive galaxies on the red
sequence, the high cosmological star-formation rate at high redshifts and the
subsequent low rate at low redshifts.
