Shia LaBeouf latest film was born in an unusual place — court-ordered rehab.

SHIA LABEOUF PLEADS GUILTY TO MISDEMEANOR CHARGE IN GEORGIA

The actor spent time writing the script for his semi-autobiographical "Honey Boy" while he was being treated for substance abuse after a 2017 arrest.

"He wrote this script in rehab and actually sent me an email from there with the script," said Israeli director Alma Har'el. "So it was pretty mind blowing. I couldn't say no to that."

CLICK HERE TO GET THE FOX NEWS APP

LaBeouf premiered the film at the Sundance Film Festival on Friday in Park City, Utah. He didn't speak with the media but posed alongside his mother, Shayna Saide, and fellow actors.

The former "Transformers" star plays an alcoholic and abusive father of a child actor, who is played at different ages by Noah Jupe (of "A Quiet Place") and Lucas Hedges ("Boy Erased").

SHIA LABEOUF'S ARRESTS AND OTHER CONTROVERSIES

"I think it was emotionally difficult for anybody to do what he did and I think nobody has ever done it before," Har'el said. "He stepped into his own trauma and played his father in it — the most complicated relationship he's ever had, that defined his life more than anything else."

LaBeouf had admired an early documentary by Har'el and they'd developed a working relationship over the years. "We did a music video. He was kind enough to finance my second film when nobody but nobody else would," she said.

In 2017, LaBeouf pleaded guilty to a misdemeanor charge of obstruction stemming from his attempt to elude police following a vulgar public outburst in Georgia.

SHIA LABEOUF ARRESTED OUTSIDE MUSEUM IN NEW YORK CITY

He was also ordered to pay $2,680 in fines and fees, perform 100 hours of community service, enroll in anger management counseling and complete a drug and alcohol evaluation. That's when he began on "Honey Boy."

Har'el said the film shines a light on LaBeouf's private struggles.

"It's a story about the things you inherit. Shia definitely inherited a lot of his passion towards acting from his father. But he also inherited other things that he has to deal with for the rest of his life. And he's trying to do it as best as he can. He had to do it in the public eye, unlike many of us. So it's been very challenging. And I think this film really kind of deals with that," she said.

"Honey Boy" is seeking a distributor at Sundance.