Halfway into “Thor,” a S.H.I.E.L.D. agent spots a group of the Norse god’s warrior friends walking down the street, turns to his partner and asks, “Is there a Renaissance Faire in town?”

It’s a joke that plays well in Marvel Studios’ first bigscreen adaptation of the comicbook character, which Paramount releases in the U.S. on Friday. But the entire $150 million pic could’ve wound up a punchline — and Marvel took great care to make sure that didn’t happen.

The potential for ridicule was certainly there: Thor is the egocentric Norse god of thunder who sports long blonde hair, wears a red cape, speaks in florid Shakespearean dialogue, uses his mighty hammer to fly and lives in a world that features a rainbow-colored bridge and otherworldly villains, including frost giants.

For fans of the “Thor” comicbooks, none of this is a laughing matter. For newcomers, it could’ve been too much unintentional comedy to bear.

“Getting rid of the cheesy elements is inherent when you’re making any comicbook movie,” Marvel Studios president Kevin Feige told Variety. “It is job No. 1: How do you make a film that appeals to a fanbase that’s followed the character for many years and an audience that doesn’t know the character at all? The majority of audiences are hearing about these characters for the first time (through the film).”

There were a lot of outlandish moments to consider from the more than 600 issues of Thor comicbooks published so far.

“There’s a comic where Thor turns into a frog, or Spider-Man puts on a paper bag over his head,” Feige said. “The sense of knowing what to pull or introduce to a new audience is always key.”

To ground the pic, Marvel tapped director Kenneth Branagh to lend his Shakespearean roots to the plot and dialogue, scripted by Mark Protosevich (“I Am Legend”). The story’s foundation has a Bard-like quality, with two brothers vying for the attention of their father, Odin, king of Asgard, Norse mythology’s ruling realm. When Thor disobeys an order, the warrior is banished to Earth to learn humility, while his mischievous brother Loki schemes his way to the throne.

“We’re telling a unique origins story,” Feige said. “It’s not about how someone gets superpowers but how someone learns to use those superpowers who is born with them.”

For Thor, Marvel suited up Chris Hemsworth, a thesp unknown in the U.S. outside his short but memorable turn as Captain Kirk’s father in Par’s reboot of “Star Trek,” and paired him with more established thesps Anthony Hopkins, Natalie Portman and Stellan Skarsgard.

“We were confident that it would be the cast and the acting and the dialogue that would win people over and help them take this world seriously,” Feige said.

Design-wise, Marvel altered Thor’s costume, covering his arms with chainmail sleeves to make him seem more regal. And though they preserved the overall look of Thor’s classic chestplate and cape, the film shows Thor wearing his signature winged-helmet only once — in a ceremony. Company wanted to keep Loki’s tall, curved helmet horns but insisted that “if we do that, let’s make the coolest version we can,” Feige said.

And the rainbow bridge (which in the comics and mythology is literally a rainbow that lets the Norse gods travel to Earth or other worlds) was changed to a luminescent, quartz-like slab with shades of rainbow colors. An observatory-like turret that uses vast energy to open space-travel wormholes was conceived by Branagh to propel characters to other realms.

But nothing protects against scorn like a few self-deprecating jokes: Thor’s fish-out-of-water scenes on Earth and human characters stumbling over the pronunciation of his hammer (Mjolnir) add humor and “pop the balloon to let (audiences) know that it’s hard to pronounce some of these names,” Feige said.

Marvel knew the fantasy setpieces could have proved a turnoff, so the script sees plenty of Thor on Earth — out of his armored suit (an early draft used a Viking-era Earth).

“You were taking audiences from one alien world to another alien world,” Feige said, so the timeframe was changed to present day.

New script borrowed from a run of the comicbooks penned by J. Michael Straczynski that saw sales surge and the character’s popularity grow.

Ironically, early reviews prefer the Asgard sequences. Marvel hopes auds are left wanting more of Thor.

For now, there’s the loads of merchandise — including Thor’s helmet, the Mjolnir hammer, Sega videogame and Hasbro action figures — on store shelves.

Next up for the thunder god: a prominent role in “The Avengers,” which Joss Whedon has started lensing for Disney to release next summer. Additional cameos in other Marvel movies and an eventual sequel, being penned by Don Payne (“Fantastic Four: Rise of the Silver Surfer”), are also planned … should this pic perform at the box office. “You only saw three of the nine realms (in the film), so there are many more stories to tell,” Feige said.

So far so good: “Thor” bowed overseas in Australia on April 21 and has already earned $125 million from foreign territories since then.