“I’m the mastermind,” one of the characters declares during the climax of “Glass,” and it’s in that moment you wonder if you’re looking right into the soul of writer/director M. Night Shyamalan. “Glass” is the third installment in the surprise “Unbreakable” trilogy, coming hot on the heels of “Split,” which didn’t reveal itself to be a true sequel to the 2000 film until its very last moments. Shyamalan is back on top of the Hollywood heap after delivering a couple of surprisingly great low-expectations thrillers, but the script for his high-profile trilogy ender is both overwrought and undercooked.

With “Glass,” Shyamalan is reminding us he is the ultimate mastermind, the king of the twists. The characters in “Glass,” especially the comic book and superhero-obsessed Elijah Price (Samuel L. Jackson), demonstrate a mastery of narrative, archetype, genre, storytelling and of course, surprising reveals. But it’s all hollow, speculative and frustratingly insistent. After the 15th twist ending, you just want to throw up your hands and yell, “We get it!”

There is a true master at work in “Glass”: James McAvoy, who reprises his role from “Split” as Kevin/Patricia/Dennis/Hedwig/Barry/Jade/Orwell/Heinrich/Norma/The Beast et al. These are the personalities of Kevin Wendell Crumb, whose dissociative identity disorder evolved as a coping mechanism from an abusive childhood. The rapid transitions between personalities turn into the James McAvoy Real Time Character Reel, but it’s truly spellbinding.

McAvoy’s performance — as well as Anya Taylor-Joy’s, as one of his kidnapping victims — were what made “Split” so juicy. Shyamalan tosses the audience morsels of McAvoy during the dour treatise on comic book morality and existential questions about superheroes that is “Glass.” This ontological analysis may have felt fresh prior to the release of “Spider-man: Into the Spider-verse” (even “Deadpool” feels more incisive), but alas, the themes are familiar, even if explored from a darker perspective.

Ultimately, much like an “Avengers” film, the goal of “Glass” is to clash the extraordinary characters together and see what happens. It’s a rumble at the mental institution when Kevin’s super-strong, bloodthirsty persona The Beast squares off with the indestructible David “The Overseer” Dunn (Bruce Willis), a troubled and taciturn superhero type Elijah rooted out during the events of “Unbreakable.”

But there’s a dank, dark air that weighs down “Glass,” and it’s only the moments featuring McAvoy where it achieves liftoff. His is a tremendous physical performance, exhausting to watch (imagine performing it), but witnessing McAvoy stretch to the outer limits of his tools is simply thrilling. Shyamalan may fancy himself a mastermind, but here, McAvoy is the true master.

MOVIE REVIEW

“Glass”

Grade: C

Starring James McAvoy, Bruce Willis and Samuel L. Jackson. Directed by M. Night Shyamalan.

Rated PG-13 for violence including some bloody images, thematic elements, and language. Check listings for theaters. 2 hours, 9 minutes.

Bottom line: Third installment gets weighed down