what three factors affect the formation of magma