On Sunday night, SpaceX launched and landed a rocket from Vandenberg Air Force Base in central California. Although SpaceX regularly launches rockets from Vandenberg, this was the first time it had landed a rocket at the facility as well. The flawless flight carried an Argentinian satellite to orbit, but the real story was the light show produced by the launch.

When SpaceX launched from Vandenberg last December, many California residents mistook the flight for an alien invasion. It’s hard to blame them. The rocket produces some crazy visual effects during its flight: It looks like a massive, iridescent cloud that has a small moving light in the center. From a distance it can be hard to tell exactly what’s going on, as Jeff Plant, a reporter for Bakersfield Eyewitness News found out during a live broadcast:

“It looks amazing, but at this point I couldn’t really tell you what is happening,” Plant said during the December launch.

To clear things up a bit, I emailed with Jonathan McDowell, a physicist at the Harvard-Smithsonian Center for Astrophysics, about what happens during a rocket’s journey to orbit. He said it’s “all about the lighting conditions.”

A SpaceX spokesperson told me the technical term for this light show is “twilight phenomena” and as its name suggests is usually limited to rocket launches that occur within an hour of sunrise or sunset. As a rocket ascends, it produces a flume of exhaust as the rocket fuel is burned. When the particles from this exhaust encounter the atmosphere, they condense, freeze, and drift through the atmosphere.

The reason this cloud of condensed exhaust looks so spectacular, however, is due to the sunlight. Even though the sun may have set on Earth, its light is still visible at high altitudes due to dispersion. This is the same phenomenon that causes sunsets to appear red.

SpaceX launch on October 7, 2018. Image: SpaceX

In the case of sunsets, when the sun is last seen from the perspective of a person on the ground, the actual position of the sun is below the horizon. This means that the refracted light from the sun has more atmosphere to travel through to reach the observer than if the sun was directly overhead. Due to the chemical composition of the atmosphere—mostly oxygen and nitrogen—the longer, red light waves don’t get scattered as much as the shorter blue light waves so the sunset appears red.

Read More: SpaceX Just Launched Its First High Speed Satellites Into Orbit

A similar principle is at work in the case of a rocket launch. In this case, the sky looks black to a viewer on the ground because the sun is sufficiently far below the horizon. Yet if you were to travel high enough, there would still be some refracted sunlight. When this sunlight interacts with the chemicals in the rocket exhaust, it creates a prism effect and scatters light at all different wavelengths. This produces the stunning displays Californians saw last night.

In the case of SpaceX rockets, this also happens during the return of the rocket’s first stage.

Here can see exhaust pulses when the first stage returned to Earth after last night’s launch:

Most SpaceX launches happen at the Kennedy Space Center in Florida, but the last two times they’ve produced twilight phenomena have been at Vandenberg Air Force Base in California. Although McDowell couldn’t say if these types of events were more common on the West Coast, he did hazard a guess as to why this might be the case.

“Maybe it's less likely to happen on the east coast because the rocket is going east, so if you are sitting in the dark it is too,” McDowell told me in an email. “While going west from California it can be dark for you, but the rocket can still see the sun.”