It’s difficult to believe that the director of this wretched medieval spoof is the same David Gordon Green who made serious independent pictures like “George Washington,” “All the Real Girls,” “Undertow” and “Snow Angels,” but it turns out that his hired-gun turn on Judd Apatow’s “Pineapple Express” was apparently no isolated detour. There’s a major difference between that movie and “Your Highness,” though. “Express” had a well-written script. The screenplay for this picture, on the other hand, is just a tired cascade of smugly unfunny riffs and gross-out adolescent raunchiness.

The explanation is that it was co-written by Danny McBride, also the movie’s star, who’s been touted as some sort of modern comic genius but on the evidence of his work thus far is just a loud, crude guy trying to get laughs with the sort of puerile material you’d expect to come from a horny high-school student who’d watched too many genre movies too many times. “Your Highness” is filled with penis jokes, dialogue that can’t seem to get past more than a line or two without the f-bomb or references to excrement, and even gags about child molestation—not to mention, of course, the inevitable gay stuff. In this case he and his co-conspirator Ben Best situate it all in the context of a take-off on medieval adventure pictures, complete with (one hopes deliberately) chintzy special effects that refer back to those in Ray Harryhausen’s stop-motion classics but come across more like the ones in Bert I. Gordon’s notorious bombs—“The Magic Sword,” anybody?

The set-up deals with two brothers, heroic Fabius (James Franco, apparently doing a favor for his pals Green and McBride from “Express,” and enduring humiliation for the good deed) and his wastrel sibling Thadeous (McBride). When Fabius’ bride-to-be Belladonna (Zooey Deschanel), whom he’s just rescued from the evil wizard Leezar (Justin Theroux), is stolen away again by the magus, the boys’ father Talious (Charles Dance) orders Thadeous to accompany his bro on the quest to free her. They’ll be joined by creepy royal counselor Julie (Toby Jones), Thadeous’ put-upon servant Courtney (Rasmus Hardiker), a group of Fabius’ “elite knights,” and his little metal bird-scout (an obvious nod to Harryhausen). Along the way there will be treachery and betrayal, but the brothers will gain a powerful ally in a spitfire female warrior named Isabel (Natalie Portman).

For the most part “Your Highness” is a snarky “Saturday Night Live”-quality take-off on the familiar genre, alternating laboriously unfunny dialogue scenes with messily chaotic action sequences, many of them crammed with junky CGI effects. These features such supposedly hilarious inventions as a Minotaur with a hard-on, a hydra that looks like a hand that has four of its “fingers” lopped off, leaving only the middle finger upraised, and a torture machine that’s supposed to end with a shot in the derriere, as it were. Until late in the game, Thadeous is a self-centered blowhard, and McBride—not a generous writer-star by any means—hogs the limelight incessantly, leaving little more than scraps to everyone else, including Franco (whose broad, stilted delivery isn’t quite as funny as his morose turn in “Tristan + Isolde” was—unintentionally, of course) and Portman (who’s forced to strip down to near nothing for a swimming scene for the young males in the audience to drool over).

For this stretch, though, the picture—while not good by any means, coming across like a juvenile version of Monty Python—is at least consistent: it means to be naughtily subversive, turning the conventions of the genre into crass jokes. But in the final act, Thadeous abruptly turns from cad to hero and saves the day. That’s predictable, of course, but predictable in precisely the sort of formulaic Hollywood fashion the movie has made a point of deriding. For all its frat-boy brazenness, the movie ultimately wimps out, and does so sloppily.

All of that is why when Thadeous’ remark when the small troupe enters the Minotaur’s den might make you chuckle. “What’s that foul stench?” he asks. The answer, of course, is that it’s coming from the screen. This “Highness” represents the lowest of comedic lows.