The writer-director — once known for pulling off a cinematic twist as well as anyone ever has, primarily in early films “The Sixth Sense” (1999) and “Unbreakable” (2000) — kept a doozy of a secret from all, apparently, but his inner circle with his well-received 2017 thriller, “Split.”

At the reasonably enjoyable film’s end, Shyamalan revealed to the movie-going world that this tale of a killer (James McAvoy) with multiple personalities — including the seemingly supernatural Beast, who possessed incredible strength and could scale walls — existed in the same narrative universe as “Unbreakable.” The latter, of course, starred Bruce Willis as a seemingly indestructible, unnaturally strong man and Samuel L. Jackson as an incredibly brittle man, but one with an extremely high-functioning brain — and, it turned out, a diabolical mind.

So now Shyamalan gives us “Glass,” an enjoyable but uneven work that unites these three characters for a tale that continues the exploration of comic-book narrative traditions the auteur started with “Unbreakable.” More engaging than it is frustrating, “Glass” nonetheless builds to an ending that can’t deliver on the intrigue and intense anticipation Shyamalan can’t help but build through the thriller’s elaborate setup.

In “Glass,” we first are reunited with The Horde, the nickname given to the collection of personalities existing within McAvoy’s Kevin Wendell Crumb, including ringleader Patricia and perpetually 9-year-old Hedwig. The Horde has kidnapped a fresh set of young women — four high school cheerleaders — who are being held captive in an abandoned Philadelphia factory and likely are to be slain, eventually, by The Beast.

We soon see Willis’ David Dunn, who has created a security business with his son, Joseph (a returning Spencer Treat Clark), but who devotes much of his energies to doling out vigilante justice at night as a hooded figure the Internet has come to dub The Overseer. Joseph is — to borrow terminology from 2017’s “Spider-Man: Homecoming” — “the guy in the chair,” helping his father find the bad guys via a computer and keeping an ear on police scanners.

And then there is Jackson’s Elijah Price, the wheelchair-confined man who works to help David reach his full, superhero-like potential, only to reveal to his protege at the end of “Unbreakable” to be supervillain Mr. Glass. He was responsible for, among other heinous acts, a train crash in which David was the only survivor.

After an early confrontation between The Overseer and The Horde, the two are brought by authorities to Raven Hill Memorial Psychiatric Research Hospital, where the convicted Mr. Glass has been living a confined, heavily sedated existence for 16 years. The contrived device Shyamalan uses to unite the three is represented in a renowned psychiatrist Dr. Ellie Staple (Sarah Paulson), who specializes in an unusual type of delusion of grandeur: people who believe they are comic-book characters with supernatural abilities.

While the constantly medicated Glass seems no threat to anyone at Raven Hill, The Horde and The Overseer are locked in rooms with mechanisms designed to specifically counteract the abilities of each. (Dr. Staple is so confident in these devices, in fact, she goes into either room unaccompanied, and the facility has only a bare-bones security staff — two of the many silly little irritations to be found in Shyamalan’s script.)

Given that the film’s title is “Glass,” it should be of little surprise that Jackson’s character will come out of his apparent haze to plot his next act of supervillainy. His scheme will, of course, involve the other two men, who, despite all the evidence to the contrary, are beginning to question whether they are, in fact, special.

Along with Joseph, Shyamalan’s story brings back into the fold another character from “Unbreakable,” Elijah’s mother (Charlayne Woodard), as well as Anya Taylor-Joy’s Casey Cooke from “Split,” whom The Beast let live because she was damaged in a similar way to him.

As Shyamalan, primarily through Mr. Glass and Joseph, drills into us various storytelling concepts comic books have used for decades, it seems as if he is building to something that will deliver a dizzying mind-blow. While some of his misdirection is effective, however, “Glass” is unlikely to shatter your brain in the end.

On the other hand, he is very successful as director here, mostly providing us with nicely executed scenes that demand your attention. Thankfully, he seems a far cry for the man who brought us largely derided middle-career films “The Happening” (2008), “The Last Airbender” (2010) “After Earth” (2013) and continues on the upward trend he began with 2015’s highly enjoyable “The Visit.”

And he benefits from nice performances from his leads. The work by Willis (the “Die Hard” series) is merely standard fare, but it’s wonderful to see Jackson (the Marvel Cinematic Universe, “Pulp Fiction”) reprise his character. Jackson’s performance is cool, measured and endlessly interesting. Even when Mr. Glass is simply sitting there, apparently knocked out by pills, you can’t help but concentrate on his sometimes-twitching eyes and wonder what’s actually going on behind them.

And then there’s McAvoy (the recent “X-Men” films), who, considering he again is given so many characters to bring to life in one very complex person, deservedly gets top billing. Some of The Horde’s inhabitants are irritating, to be sure, but McAvoy gives them all his all and is enjoyable to behold.

“Glass” is labeled the final chapter in a trilogy, but Shyamalan leaves this “Unbreaka”-verse seemingly rife for further exploration. Unfortunately, the final act of “Glass” is cracked to the point where you don’t leave the theater craving that.

“Glass” is rated PG-13 for violence including some bloody images, thematic elements and language.

Mark Meszoros is the assistant managing editor/features for The News-Herald in Willoughby, Ohio and the entertainment editor for The Morning Journal in Lorain, Ohio.