David Bowie has been called the greatest rock star ever. Clearly that title could apply to a clutch of top musicians, but few observers would deny his vast influence not only on music but also on the worlds of fashion, popular culture and even gender identity.

Producer-director Francis Whately takes an in-depth look at Bowie’s remarkable creative output in the final years of his life — albums “The Next Day” and “Blackstar” as well as the musical “Lazarus” — in the documentary “David Bowie: The Last Five Years,” which premiered Jan. 8 on HBO.

Whately is quite familiar with his subject. In 2013, he made the film “David Bowie: Five Years,” which focused on the early 1970s — years when the performer first established himself. When the BBC, another of the film’s distributors, approached the director about a follow-up after Bowie died in January 2016, the filmmaker wasn’t sure he had it in him. “Much as I am a fan, I didn’t know whether we could do anything that would be substantially different to the first film,” he says.

Whately ultimately realized he could use the work Bowie produced near the end of his life — some of it while he was battling liver cancer — as a springboard to the past to more deeply explore themes of fame, alienation, otherness, space and spirituality, which were constants throughout the rock icon’s career. “The challenge was that this time in Bowie’s life was undocumented,” Whately says of the current movie. Bowie didn’t give press interviews, and other than the music videos he appeared in, there wasn’t much archival footage available.

So Whately devised a twofold solution: He reunited the musicians who had made Bowie’s last two albums, re-creating what it was like to be in the studio with the artist, and he shot a performance of “Lazarus” at the New York Theatre Workshop.

He also employed a tenacious archive producer, Miriam Walsh, to dig up footage from throughout Bowie’s career. “She can find things. She’s very, very good at her job,” Whately says, noting that Walsh sourced never-before-seen material, including footage of Bowie becoming visibly annoyed at being filmed while talking with artist Damien Hirst at an exhibit in New York City. “I think it’s a very telling moment for a man who was desperate for fame, and then had a very ambivalent relationship with fame,” Whately says.

Other unseen archival finds include a black-and-white clip of Bowie singing “Lady Stardust.” The footage was silent, but Whately’s editor, Ged Murphy, got a bootleg recording of the song and married the audio with the visual. On a project like this, “you have to work with an editor who not only knows what he’s doing and is visually creative but also someone who understands music,” Whately says.