The ionizing background determines the ionization balance and the thermodynamics of the cosmic gas. It is therefore a fundamental ingredient to theoretical and empirical studies of both the IGM and galaxy formation. We present here a new calculation of its spectrum that satisfies the empirical constraints we recently obtained by combining state-of-the-art luminosity functions and intergalactic opacity measurements. In our preferred model, star-forming galaxies and quasars each contribute substantially to the HI ionizing field at z~0.5 keV) photons permeates the entire universe owing to the frequency-dependence of the photoionization cross section. We provide an analytic model of the heat input during HeII reionization and its effects on the temperature-density relation.