Galaxy formation with radiative and chemical feedback