Sadness must be the defining feature of existence as a ghost, where you are doomed to drift through the remnants of a life that’s still there but forever out of reach.

“A Ghost Story,” the new movie from David Lowery (“Pete’s Dragon”) starring Casey Affleck and Rooney Mara, operates from the perspective of the titular supernatural being and evokes the poignancy of his condition.

“Any one of us who imagines ourselves passing on, wishes we could console the people we’re leaving behind,” says Lowery, 36, who also wrote the screenplay. “That’s a beautiful, sentimental thought.”

The movie, opening in theaters July 7, follows a husband (Affleck) who dies in a car crash and returns under the white sheet placed over him in the morgue to the small home he shared with his wife (Mara). There, he silently observes as she mourns his loss.

“I do kind of believe in ghosts,” Lowery says. “But I’ve never had an encounter with them. If ghosts do exist, they are unable to get in touch with me. But then again, I would assume they’re having trouble getting in touch with anybody else.

“And so what are they doing? They must just be sitting there watching,” Lowery adds. “That is such a sad thought, such a bone-deep concept, that I wanted to represent that, I wanted to represent that alienation and show a traditional haunted house movie from the point of view of a ghost who is unable to actually make the contact that he wishes he could make.”

Affleck, fresh off his Oscar for “Manchester by the Sea,” spends a large portion of the movie shrouded in that white sheet, his movements restricted to the point where the slightest turn of his head becomes engulfed in deep significance.

Carrying out the concept and presenting a full sense of the ghost’s experience posed a steep challenge for both the actor and the filmmaker.

“It was a different sort of challenge than I initially thought, because I thought initially that I wanted to have Casey’s performance be very recognizable under the sheet,” Lowery says. “I wanted his body language to come through and I wanted him to be very physical. And we tried that, and it just wasn’t working. Whenever we could tell that Casey was under the sheet, the ghost was failing because it wasn’t achieving the presence that it needed to have to function as an actual spirit in the film. So we had to iron out that performance.”

The solution became that Lowery would feed his star stage directions as the cameras rolled, telling him where to go, what to do and how to do it, in a fashion that the filmmaker says restricted any sort of traditional acting.

The ghost, then, is simultaneously the protagonist of the movie and a nonentity.

Presenting him as such complicates the filmmaker’s depiction of loss and grieving by focusing on a fundamental truth.

“I think about how when someone passes away, it’s not really them you’re sorry for, but yourself. And how you define their absence by how you feel,” Lowery says.