Moviegoers and comics fans were, by and large, sold on Captain Marvel once Brie Larson was announced as the big screen Carol Danvers, and any doubts were erased after the debut of the film's first trailer. There was one moment in particular that announced the movie's style and earned the immediate meme treatment: Danvers picks out an elderly woman sitting on an elevated train and punches her in the face, just wailing the fragile senior as hard as possible.

As many astute fans guessed and many more learned once they saw the movie, Carol was right to slug granny, as she's actually a shapeshifting alien species called a Skrull and far more green and reptilian in true form. Captain Marvel is chock full of facial transformations, both inter-species and across human appearances, featuring de-aging VFX (used on co-stars Samuel L. Jackson and Clark Gregg) and full-on replacements. The granny wallop was produced with the latter technique, and so if logic hadn't already relieved your fears, you can rest easy knowing that no elderly woman was injured on the set of Captain Marvel.

That doesn't mean, however, that there wasn't a senior woman on set, going through the beats of a wild fistfight with Brie Larson.

Video of Marvel Studios' Captain Marvel - Official Trailer Courtesy of Marvel Entertainment

The granny punch, which was part of a larger action sequence on a train, was pulled off using a technique called a Texas Switch, a relatively old method that has become essential in movies with high-octane fight scenes. Here's how it worked in this case:

As VFX supervisor Kevin Souls explains to SYFY WIRE, when the granny was sitting calmly in her seat, she was portrayed by Marilyn Brett, an older actress whose face we'll call the actual granny's face. When the granny character is engaged in action, she's played by a stunt woman, who performs fast-paced acrobatics — she spins around a pole at one point, feet-first — and gets her face smashed against said pole.

Once those shots were complete, the production team tapped Brett to show off her stuff.

"The granny would then move through the scene slowly in approximately the same sort of movement and position as reference," Souls says. "We would extract that performance and track it onto the stunt actress face in 3D."

Credit: Marvel

It wasn't as easy as a one-for-one trade, like some kind of Photoshop gag. Because they didn't have Brett take a fist to the face, it was actually more of a blend of mugs with a bit of extra computer manipulation. "We'd use part of the stunt person's face that was really punched, and part of the other actress' face," Souls explains. "And then we would work to get the mouth open or closed and we would animate parts of the face to get expressions to change subtly."

Larson's face was also put on the body of a stunt double for much of the sequence, and it was seamless enough that it likely comes as some surprise to casual moviegoers — much more so than the granny punching replacement, anyway.

The generational scrap was just one small part of the larger sequence, and according to Souls, one of its simpler elements. The whole sequence features Captain Marvel hunting down Skrulls on an elevated train winding its way through Los Angeles, while Nick Fury and Phil Coulson, digitally de-aged and looking great, try to keep up on the streets below. During production, the sequence was codenamed 'The French Connection,' adopting the title of the classic '70s flick with maybe the most famous car-train chase scene of all time.

Luma Studios, where Souls works, was responsible for this sequence, which was shot in several segments all over Los Angeles. It begins when Danvers is confronted by Fury, who has no idea who she is at this point. Danvers grows tired of the exchange, jumps a rail station turnstile, and boards the train, where the fighting begins. The fighting later moves to the top of the train car, and then the train goes from its elevated position to a street-level track. The simultaneous car chase, which causes bad L.A. traffic to get even worse, with collisions and spin-outs, featured actors who would later be digitally de-aged.

The sequence uses a grab-bag of advanced VFX techniques, necessitated by the tweaks to Los Angeles geography and the sheer impossibility of shooting actors fighting atop a fast-moving train, among other issues. The production was able to take command of a few active train cars and part of a rail line, which allowed for the most in-camera parts of the sequence. But they were only able to secure private time on so much of the train line — L.A. does still operate its rail, though that may be a surprise to some — and so a lot of the environment had to be captured separately, for later placement into background plates.

"We started by shooting array footage of the train line from the train tracks, which means we had a specially modified truck that can drive onto the train tracks," Souls explains. "We mounted these cameras that shoot essentially a combined 360-degree rotational view of the environment. And we drove that car down the entire length of the track where we were going to be doing the fight scene. We did that so we had backgrounds for the entire fight if we needed them for the blue screen work."

Credit: Luma/Marvel

That explanation sort of belies the work that went into the project. It wasn't as simple as just inserting trees and buildings into the blue screen background on those shots. The 360-degree footage of L.A., starting at the Pico Aliso station, wasn't just photography — they captured LIDAR data, which gives spacial information about physical locations and the distance between items in the environment. The team at Luma used that data to reproduce the scenes they shot in 3D, and then used a virtual camera to "film" the exact coordinates and route that they needed to match the train's path.

This was helpful both for the fight scene on top of the train, which was shot in a static rail yard surrounded by green screen, as well as the moving train scenes that did not have the right environmental continuity.

"There are other parts of the sequence that are complete CG replacements jammed into the live-action that are pretty invisible, as well as complete environment replacements for the areas surrounding the car," he says. "There's some things that people would never suspect are full CG and other parts people think are CG that are just photographic.

Even the most grounded moments, on the street, are enhanced with 'invisible' computer effects and replacement environment.

"A bunch of sequences where it is full photography, we ended up for continuity having to replace everything around the car with either full CG or with a mostly augmented environment to tie the scenes together," Souls says. "On the left side of screen, Coulson and Fury are racing down the street and they're swerving through cars — that entire environment was replaced with a virtual reproduction so that we could tie that environment with the Pico Aliso and the environment before."

Everything in this sequence, it turns out, is a bit of a shapeshifter.