There’s grime, grit and dust to spare in The Yards, writer-director James Gray’s new film about corruption and murder inside New York City’s subway system. After two hours in the theater, you’ll be marveling at the nearly palpable texture of this exceptionally photographed film noir — even though you might feel the need for a shower, as well. The Yards thrives on energy from the chiaroscuro, hushed tones and towering shadows of the noir genre. One of the film’s most appealing aspects is its decidedly uncinematic venue. The New York City transit system — even when painted as hopelessly corrupt and shady — isn’t up there with, say, a larger-than-life, close-knit family of Italian mobsters for reflexive cinematic value, but Gray takes obvious delight in showcasing the subterranean setting in ways we’d never have expected. The story has been told a few times before, though. Mark Wahlberg plays sad-sack Leo Handler, just sprung from prison after taking the fall for a car-theft ring involving Willie (Joaquin Phoenix), his best friend. Leo wants to go straight and care for his ailing mother, but slick Willie talks him into doing a simple little vandalism job for his uncle Frank (James Caan), who owns a shady repair business that bids on subway-maintenance contracts. Needless to say, things go terribly wrong. Leo is soon on the run for something he didn’t do. Complicating matters is the fact that Leo has the hots for his cousin, Erica (Charlize Theron, flaunting a flawlessly exaggerated “Noo-Yawk” accent) — who also happens to be Willie’s girl. (Please take notes, because Gray gives a test in the final reel.) Gray gives his actors ample opportunities to steal scenes, and most have no qualms about it. Phoenix rants and raves, while Wahlberg’s Leo doesn’t talk much but revels in flashing fire in his uncomprehending eyes. Both actors look their parts splendidly. Wahlberg, poured into an ill-fitting shirt and tie, makes for one of the film’s most memorable images. Several supporting performances also hum, most notably Caan’s friendly menace as the film’s “Godfather” figure. The Yards’ family drama becomes more compelling than its crime drama, which strains under the weight of ’40s gangster-film improbabilities. If Gray sometimes rambles loudly and sometimes keeps things too quiet, they are only the flaws of a director smudging small corners of a large canvas. He moves seamlessly through several mini-confrontations, quickly disposing of exposition that would take many writer-directors an hour or so. The Yards’ problems come late, when its weight as a morality play sits a bit too heavily. It’s unsatisfying, but only because our hopes were raised so high. The atmosphere of The Yards will stick with you long after the plot leaves. It’s more than noir: It’s a solid bite of urban reality.