"You painted this room purple and WE'RE the crazy ones?!"

Picking up a few weeks after “Split” and 18 years after “Unbreakable,” M. Night Shyamalan’s “Glass” concludes his weird comic book trilogy by bringing all the main players together, crossover-style. That includes David Dunn (Bruce Willis), the security guard who discovered in 2000 that he was virtually indestructible and could see people’s sins when he touched them (a “sixth sense,” if you will); Elijah Price (Samuel L. Jackson), the brittle-boned comic book enthusiast aka “Mr. Glass” who positioned himself as David’s archenemy; and Kevin Wendell Crumb (James McAvoy), the multiple-personality serial killer from “Split” whose horde of internal voices includes a superhuman beast.

These three are classic comic book archetypes — the reluctant hero, the brainy villain, and the remorseless anarchist — but Shyamalan isn’t building toward a classic comic book showdown, at least not in the usual sense. Expecting “Glass” to be a superhero movie, even an M. Night Shyamalan version of one, is the surest path to disappointment.

It is, instead, a nerdy deep-dive into the filmmaker’s ideas about superhero movies, featuring deconstruction of comic book storytelling mixed with suspense tropes. The title character initially seems to have been given that honor simply because it’s his turn (the unbreakable man and the split man already had theirs), but it proves to be thematically appropriate. He may not be the protagonist, but Elijah Price’s existential quandary — “What is my place in this world?” — is at the center of the movie.

David has spent the years since “Unbreakable” running a home-security store by day, being an avenging angel by night. Dubbed “the Overseer” by the media, he’s assisted by his son, Joseph (Spencer Treat Clark), who stays back at the Batcave watching David’s body-cam feed and advising him via earpiece. Finding the still on-the-loose serial killer from “Split” is a top priority, but so is avoiding detection by the police, who don’t like vigilantes because the cops are a bunch of squares.

Elijah Price, meanwhile, has spent the intervening years doped up in a hospital for the criminally insane whose name, like many movie asylums, has the word “raven” in it. David and Kevin Wendell Crumb both end up here, too, and we get to the meat of the story, wherein Dr. Ellie Staple (Sarah Paulson) tries to treat their “delusion” of being superhuman. She works specifically with people who think they have comic book powers. This is a bit of a non-starter for the audience — we’ve seen these guys in action; it ain’t no delusion — but it’s enough to make David start to doubt his sanity. David’s son and Elijah’s mother (Charlayne Woodard) are eventually involved, as is Casey Cooke (Anya Taylor-Joy), the girl who escaped from Kevin at the end of “Split” after developing affection for his true, un-crazy persona.

As a fan of “Unbreakable” and “Split,” I like how Shyamalan combines the comic book elements of the former and the horror elements of the latter into the nutty, self-aware, periodically thrilling amalgamation that is “Glass.” (The tie-ins to “Unbreakable,” including the use of its deleted scenes, are also well done.) Elijah isn’t just the physically weak madman who teams up with a brutish thug to achieve his goals; he’s the madman who’s fully aware that this is how it always plays out in the comics, who believes he’s fulfilling his destiny by becoming a comic book supervillain and comments on it frequently.

But Shyamalan is dead-set against giving us what he sets us up to want. He even teases a specific third-act climax and then devilishly (annoyingly?) doesn’t provide it. The story spirals into lunacy and the conclusion is unsatisfying, though it’s hard to say just how unsatisfying Shyamalan meant it to be. I suspect his thinking was, “It’s so different from what you thought it would be! Isn’t that great?!”

But I enjoyed most of the movie, different though it was from expectations. James McAvoy delivers another amazing performance as the multi-minded Kevin, giving each of his personalities his or her own voice, walk, and mannerisms, switching between them without missing a beat. The content may be frivolous, but the skill required to pull it off convincingly is masterclass-level. And while I wish there had been another sequel somewhere that focused on David and Joseph Dunn’s crime-fighting escapades, we get an exciting snapshot of them here that will have to suffice. I don’t like all of Shyamalan’s choices, but I sure get a kick out of watching him do exactly what he wants to do.

B (2 hrs., 8 min.; PG-13, a little mild profanity, some moderate violence.)