The new film “Chasing Mavericks” might never have happened if it weren’t for a chance encounter between Jim Meenaghan and young surf legend Jay Moriarity at a Santa Cruz surf shop in 1994. When Meenaghan, a corporate lawyer and rookie surfer, and his wife met the 16-year-old Moriarity, who was revered in Santa Cruz after conquering the mythic surf of nearby Mavericks, which often boasts 60-foot swells, they understood the town’s adoration.

“People always said he had a glow about him. We realized we were talking to someone who radiated a little bit,” Meenaghan reflected recently. “We always remembered that.”

Moriarity re-entered Meenaghan’s consciousness in 2001, when the surfer’s untimely death in a free-dive accident off the coast of the Maldives was reported. Meenaghan, who by then had become head of Walden Media’s business affairs, decided to moonlight as a movie producer and tell Moriarity’s story. It turned out to be a very scary ride.

In the film, which opened last Friday, an unorthodox surf coach, Frosty Hesson, played by Gerard Butler, teaches the fatherless Moriarity (newcomer Jonny Weston) about riding the big swells while interjecting some life lessons. He specifically delineates the crucial difference between fear and panic: “Fear and panic are two separate emotions,” says Butler’s character in the film. “Fear’s healthy. Panic’s deadly.”

The filmmakers behind “Chasing” Mavericks needed to follow Hesson’s advice when their already challenging production — capturing the massive Mavericks waves is no easy task — had to contend with director Curtis Hanson falling ill, an injured leading man and unfavourable weather.

“Under the circumstances, the movie is a lot better than it has a right to be,” screenwriter Kario Salem said about the film, which opened to mixed reviews. “Even though all this happened, things never spun out of control. We had really talented people working really hard, who knew what their jobs were and believed in the material.” Meenaghan partnered with his friend, and fellow surfer, Brandon Hooper and spent three years nailing down the life rights to the project and developing it at Walden Media. The duo was bolstered with the hiring of writer Salem, who found his own take on the surfing tale — that the student ultimately becomes the teacher.

Since the moment Hooper boarded the project, he wanted the Oscar-winning Hanson at the helm. Having seen “L.A. Confidential” and “8 Mile,” Hooper knew Hanson was the one to go deep into a specific subculture. And though he wasn’t a surfer, Hanson spent a lot of time in Marina del Rey, driving a beat up Cadillac with a bunch of beach towels in the back to play volleyball with old-timers in the area.

“He got into these worlds and looked at them from the inside out,” said Hooper, who accompanied Hanson on an early test shoot to Mavericks to see if the director could capture the authenticity of the big-wave surfing experience.

“Chasing Mavericks” finally entered production in September 2011 — five years after Hooper and Meenaghan secured the rights to Moriarity’s story and with the help of veteran producer Mark Johnson, who joined the film a few months before filming began to help shepherd the production. Hooper moved his wife and two elementary-school-age children up to Santa Cruz for the year, while Meenaghan, who had become the head of business affairs at United Talent Agency, flew up on the weekends. They were immediately challenged by a La Nina weather system that produces smaller waves. After slogging through two-thirds of the film’s 37-day shoot in Northern California, Hanson left the movie due to a serious illness. (Twentieth Century Fox, the distributor and co-financier of the film, would not elaborate on details of his sickness.)

According to Meenaghan, the Directors Guild of America allowed the crew to continue filming for a handful of days without a director before Walden Media replaced Hanson with Michael Apted, who had recently shot the latest chapter in “The Chronicles of Narnia” for the company. “It was so hard on so many levels when Curtis got sick,” said Hooper. “He’s not only my close friend but he’s the master and commander of the set. It was a very tough, tough time. I think what really made it touching is we became a family on that set. When he fell ill, it was like ‘Dad’s not well, let’s get through this for him.’”

The drama didn’t end there. Butler was swallowed by one of those mythic Maverick waves.

“He almost died,” added Hooper. “When you are getting rag-dolled under the water like that you immediately panic. He was underwater for almost 45 seconds. They couldn’t get his heart rate down for about 48 hours after that happened.”

Butler’s injury occurred during the film’s massive second-unit shoot, helmed by Phil Boston, which lasted six months until the famed surf shooter got the 50-foot waves he needed to fulfil Hanson’s initial vision for the film.

Yet Butler and Salem were both concerned that the opening and closing scenes of the script that Salem initially wrote weren’t ever filmed — simple shots that show a silhouetted man swimming under the water. The duo made a deal with the studio to front the cost for the $50,000 one-day shoot in Hawaii. If the studio used the footage, the writer and star would be reimbursed. The plan worked, and “Chasing Mavericks” now begins and ends with a shot of Moriarity diving underwater.

During that quick trip, Salem took Hooper and Weston to a quiet surf spot adjacent to the busy Waikiki beach. All three surfed until the sun set — a moment of respite to conclude an arduous journey. “It was a perfect moment in time,” said Salem. “Celebrating being in the water and getting this far.”