It’s a long way from Australia to Hollywood, but Danielle Macdonald had to go a bit farther — to Robert Redford’s Sundance resort in Utah County — to land the role that could very well make her a star.

At the time, Macdonald wasn’t sure what director/writer Geremy Jasper had in mind.

“I thought, What on earth has he seen that makes him think I can do this?” Macdonald said in a recent phone interview. “I definitely didn’t think I could. It’s so different from me. He called me and said, ‘I feel like you can.’ He had faith in me.”

Macdonald stars as Patti Dombrowski, who aspires to get out of her miserable New Jersey existence by becoming a rap superstar, in “Patti Cake$,” Jasper’s joyous up-from-nowhere story that earned standing ovations at this year’s Sundance Film Festival. The movie is now rolling out into theaters nationwide. (It opens Wednesday in Salt Lake City.)

Jasper workshopped his script for “Patti Cake$” at the 2014 Sundance Filmmakers Lab and was asked to form a preliminary cast to work on scenes. But choosing someone to play Patti, a character he created based on people he knew in his native New Jersey, proved difficult.

Jasper envisioned the plus-size Patti as “a combination of Mae West and Biggie Smalls, with a dash of Tony Soprano and my mom, and the heart of Bruce Springsteen,” he said. In casting, though, “nobody felt right, nobody felt like the women I grew up with, nobody felt like the Patti that was living in my imagination for all those years.”

Then his producer, Noah Stahl, remembered Macdonald from a small role in “The East,” a 2013 eco-terrorism drama that starred Brit Marling and Alexander Skarsgård.

“The second I saw [her photo], I said, ‘That’s Patti. That’s her. That’s the face. That is Patricia Dombrowski,’” Jasper recalled. He said he called up Macdonald, who “was very shy on the phone and said, ‘I don’t know if I can do this.’ I told her, ‘Let’s try it. You come out to Utah, we’ll try it. If it’s a disaster, it’s a disaster.’… I knew within 10 minutes that she was going to play Patti.”

“He wasn’t asking me to audition or anything, and I thought [that] was really weird,” Macdonald said. “I said, ‘I don’t rap, I can’t do a Jersey accent, but I’ll come out. I’m warning you.’”

Jasper brought two other actors to the Sundance lab, both of whom star in the movie: newcomer Siddharth Dhananjay, who plays Jheri, Patti’s Indian-American best friend and cheerleader; and comedian and cabaret singer Bridget Everett, who plays Patti’s mom, Barb, who performs drunken karaoke to recapture her ’80s pop-singer glory days. (Rounding out the cast are Mamoudou Athie as an avant-garde musician who becomes Patti and Jheri’s collaborator, and “Raging Bull” star Cathy Moriarty as Patti’s chain-smoking nana.)

Actress Cathy Moriarty, from top left, actor Mamoudou Athie, actor Siddharth Dhananjay, actress Danielle Macdonald, from bottom left, writer/director Geremy Jasper and actress Bridget Everett pose for a portrait to promote the film, "Patti Cake$" at the Music Lodge during the Sundance Film Festival on Sunday, Jan. 22, 2017, in Park City, Utah. (Photo by Taylor Jewell/Invision/AP)

Everett, Jasper said, “is like a legend in New York. You can’t walk down the street without people yelling her name or asking for her autograph or her picture.”

Jasper saw Everett on “Inside Amy Schumer,” and “immediately I saw that that’s Barb.” Seeing her perform her bawdy cabaret act (which can be seen in her 2015 Comedy Central special “Gynecological Wonder”), Jasper said, “I could sense this darkness inside of her, this emotional depth. … I just could imagine her at 2 o’clock in the morning, at a blues bar, singing Bon Jovi ballads at karaoke.”

“She didn’t go for it right away,” Jasper said about Everett. “It took some convincing to get her to come. She was used to being in her comfort zone, and this brought her out of that.”

Jasper said he knew it would work while at the Sundance Lab when he filmed a hard dramatic scene, when Barb dresses down Patti and belittles her musical dreams.

“I could just see Bridget morph into this beast,” Jasper said. “And Danielle, who’s a big woman, suddenly shrank. … Bridget was so towering and so intense. She was like a cat who had wounded a mouse and was just playing with it like a toy. She was so large, and so looming over Danielle. She made Danielle feel and look like she was 6 years old.”

Another element of “Patti Cake$” is the rap performances, which stretched Jasper and Macdonald.

“I almost invented Patti as an alter ego so I could write the music I would want to write in a perfect world.” Jasper said. “She got to say things I wish I could say. … She was my avatar.”

Jasper, who co-directed (with his wife, Georgie Greville) music videos for such artists as Selena Gomez and Florence + The Machine, wrote 14 rap songs to tell Patti’s story and went into the studio with Macdonald to record them before filming started.

When it came to rap, Macdonald said, “I knew what I heard on the radio.” She dived into rap history and found a particular kinship to the Notorious B.I.G.

“I love Biggie so much,” she said. “When I started playing Patti, I didn’t realize how much I would connect to his music. He made me feel more like Patti than anyone else.”