Cosmic cloud formation