Thesis: Diffuse gas emission: From large-scale structure to galaxy formation