Marvel Studios President Kevin Feige has revealed exactly how the roles Stan Lee would play in Captain Marvel came about, making it clear it all came from a place of joy and Lee's overall love for the entertainment industry.

In terms of the opening credits, which paid tribute to the late Lee, Feige echoed directors Ryan Fleck and Anna Boden sentiments that it was all down to the studio's visual development team, who listened to feedback that Lee would want a memorial to be inspiring and fun once he died.

RELATED: Captain Marvel Almost Had a Major Thor: Ragnarok Connection

"We've been thinking for a number of years, very rarely and not that often, what would we do if, what would we do when, and we had certainly hoped it would be decades from now," Feige said to /Film. "But that the films themselves are the tribute, the films themselves are what we worked so hard on to do right by his creations and the creations of all of his collaborators and co-creators. And because Captain Marvel was the first one since his passing, we want it to kick the movie right away off with a tribute that feels celebratory as opposed to mournful."

"We'd been told by people close to Stan that he didn't want people mourning or being sad, he wanted to celebrate. And that was something that came together soon after he passed. And our visual development group did all those beautiful sketches at the top of it," he added. "And then of course, we put in all the cameos. And I don't know how many times you’ve seen it, but there's even some B-roll of him with our cast and our filmmakers. It's not just clips from the movies in that logo."

As for Lee's cameo, where he's seen on a train reading a Mallrats script, playing himself, Feige indicated it was a totally collaborative effort that they wanted to be as meta and as funny as possible.

"And his cameo, it's great because it's the first time he's playing him. He's himself in 1995 reading a script, practicing lines," continued Feige.

RELATED: Captain Marvel: Gal Gadot Congratulates Brie Larson on Film's Success

"That was the idea a long time ago when the script was going together. How do we integrate 1995 Stan? And the idea while making this movie and developing this movie, we sort of had lists of everything that happened in every year of the early nineties," he said. "And his cameo Mallrats was a big one. Yeah. So I don't remember exactly who had the idea. I think it was Anna and Ryan who had the idea. That he was looking at a Mallrats script, and I spoke to [Mallrats writer/director] Kevin Smith and got his sign off on."

Directed by Anna Boden and Ryan Fleck from a script they wrote with Liz Flahive, Carly Mensch, Meg LeFauve, Nicole Perlman and Geneva Robertson-Dworet, Captain Marvel stars Brie Larson as Carol Danvers, Samuel L. Jackson as Nick Fury, Jude Law as the commander of Starforce, Clark Gregg as Phil Coulson, Lee Pace as Ronan the Accuser, Djimon Hounsou as Korath the Pursuer, Gemma Chan as Minn-Erva, Ben Mendelsohn as Talos, Lashana Lynch as Maria Rambeau, Algenis Perez Soto as Att-Lass, McKenna Grace as a young Carol Danvers and Annette Bening as the Supreme Intelligence.