  We present hydrodynamical simulations of the formation of galaxies in the
mass range 10^9 - 10^13 solar masses, with the focus on the efficiency of gas
cooling. The effect of a background UV radiation field, and the effect of metal
enrichment of halo gas due to star formation and stellar evolution, are
investigated. A background radiation field is found to strongly suppress the
formation of galaxies with circular velocities less than approximately 50 km/s.
The effect is, however, not large enough to reconcile hierarchical clustering
models with observations. Metal enrichment of the halo gas increases the
cooling rate at low redshifts. We find that the mass fraction of gas at virial
temperatures may be reduced by a factor of two, in simulations with a UV
background field added. The decrease in overall efficiency of gas cooling due
to the inclusion of a UV background field can be more than compensated for by
the increased cooling that follows metal enrichment of halo gas, but the effect
may depend strongly on the assumed model of metal enrichment.
