It’s one of history’s perverse twists that Nikola Tesla—the wildly brilliant inventor who died penniless in a New York hotel—is overshadowed by an electric-car company owned by a Twitter-trolling billionaire. But the 63-year-old filmmaker Michael Almereyda understands the wonders of Nikola Tesla very well—he cast Ethan Hawke to play the brooding Serbian-American scientist in Tesla, a Sundance award winner from 2020.

Almereyda is an éminence grise of New York independent cinema, a restless intelligence who has made films about the psychologist Stanley Milgram and the photographer William Eggleston, written screenplays for David Lynch and Wim Wenders, and re-envisioned Hamlet and vampire mythology for the streets of Manhattan.

Almereyda in SoHo, 2015.

Almereyda’s new book, Tesla: All My Dreams Are True, is an engrossing, witty reflection on moviemaking and history, hypnotically unfolding in what feel like meetings of the mind across time. The title comes from a line that Hawke came up with for the film. “He wrote some of the best lines,” Almereyda said over coffee at a diner recently.

The film recounts Tesla’s innovation of alternating current and how he crossed wires with Thomas Edison, George Westinghouse, and J. P. Morgan, who financed his later fanciful project of a wireless transmitter of electricity. During filming, Hawke would send iPhone videos of himself reciting Tesla quotations, sometimes using filters, trying out a voice at one point modeled on Tom Stoppard’s.

Previously, Hawke had been Almereyda’s Hamlet for a 2000 film. “I realized that no one had made a version of Hamlet with a young actor,” said the filmmaker, who set the movie in millennial New York, also casting Kyle MacLachlan as a C.E.O.-style Claudius and Sam Shepard as the ghost.

The real-life Nikola Tesla.

“Shepard called me up through Ethan when he learned we were doing Hamlet,” Almereyda said. “He called to play the ghost.” Almereyda hoped to cast Shepard as Mark Twain in Tesla, building on an actual 1894 encounter when the writer visited the inventor’s lab located on what is now West Broadway. Tesla: All My Dreams Are True devotes a touching passage to how this particular dream didn’t come to pass. Shepard scaled back because of a diagnosis of A.L.S. (Lou Gehrig’s disease) and retired to Midway, Kentucky. Almereyda left the Twain idea alone. “I didn’t care to think of anyone filling Sam’s shoes,” he writes.

While Hawke and Shepard did not re-unite in Tesla, the film did bring together MacLachlan and Hawke again. The Twin Peaks star plays Edison, who becomes Tesla’s nemesis, far savvier in business. Much of the film traces Tesla’s frustrated progress and his fantasia of ideas, partly told through the inspired narration of J. P. Morgan’s daughter, portrayed by Eve Hewson.

MacLachlan unleashes another chain of associations: the Twin Peaks mastermind, David Lynch, produced Almereyda’s downtown vampire film, Nadja, starring the Romanian-born 90s indie avatar Elina Löwensohn. Lynch stepped up when Nadja teetered after Eric Stoltz had to bow out. “David was brave and generous and said he’d pay for it. So to this day, he owns the movie,” Almereyda said. “He just granted streaming rights for a week through Le Cinéma Club, so you’ll be able to see it there.”

Kyle MacLachlan as Thomas Edison, in Tesla.

Did I mention that Peter Fonda plays Van Helsing in Nadja? Forget about Kevin Bacon—try six degrees of Michael Almereyda. At the time, Stoltz was dating Bridget Fonda, and her father got wind of the film. “He was the youngest person on the set, I was fond of saying,” Almereyda recalled. The Easy Rider icon apparently insisted on wearing his hair long to play the vampire killer, declaring via fax: “Let my freak-flag fly!”

Almereyda remains a fixture of the New York film scene (and an eloquent critic on cinema himself, recently interviewing David Cronenberg for Filmmaker magazine). His book completes a journey begun 40-odd years ago, when he first dropped out of Harvard to finish a script on … Nikola Tesla. (The knack for attracting talent was present early on—his short from 1985, “A Hero of Our Time,” stars Dennis Hopper, whom he reached through the eminent art curator Walter Hopps.)

Like many in film, Almereyda has written more scripts than could be made—among them, an early version of Total Recall. (One exchange of his that survives in the Arnold Schwarzenegger film: “What if this is a dream?” “Then kiss me before you wake up.”) Almereyda’s book parts the veil on a dreamscape of imagination and history, taking us through the ideas and personages explored through his films, both made and unmade.

“I always worry when people talk about boredom,” Almereyda said. “I don’t have that capacity, especially when making a film.”

Tesla: All My Dreams Are True, by Michael Almereyda, will be published on October 25 by OR Books

Nicolas Rapold is a New York–based writer and the former editor of Film Comment magazine