Ben Stiller’s Tropic Thunder doesn’t even wait for the film to start to get offensive. Before the credits roll, it disorients you with an “ad” for Alpa Chino’s Booty Sweat Energy Drink, a trailer for Jeff Portnoy’s comedy sequel, The Fatties, Fart 2, and another trailer for Aussie star Kirk Lazarus’s new film about gay monks in the Middle Ages, Satan’s Alley. Consider yourself warned: if these assaults on good taste don’t drive you out of the theater, you’ve only yourself to blame if you’re outraged by Tugg Speedman (Stiller) doing the “full retard” in Simple Jack.

If you choose to remain, however, you’ll be treated to one of the summer’s funniest comedies (Pineapple Express and next week’s Hamlet 2 might have the edge), and as opposed to Grindhouse, in which the best parts were the mock trailers, these teasers are no tease. Despite a few soft spots along the way, Thunder combines the dark absurdity of Stiller’s underrated Cable Guy with the unrestrained dumbness of his Zoolander. And for those so inclined, it offers a primer on the past 50 years of film history and a workshop on acting technique.

It opens with a parody of that milestone in auteur hubris, Apocalypse Now. Fitting uncomfortably into the Francis Coppola role is untested British director Damien Cockburn (Steve Coogan), who’s making the Vietnam War film of the title under great duress. A lot of the pressure comes from the producer, Les Grossman (an uncredited and unrecognizable Tom Cruise), who combines the least charming traits of Joel Silver, Scott Rudin, and Attila the Hun. And a lot of the stress comes from the three stars in the cast. Portnoy (Jack Black) has a drug problem, Speedman’s career is collapsing, and Lazarus (Robert Downey Jr.) has submerged himself in his role. To play Lincoln Osiris, the African-American sergeant, Lazarus has had his skin pigment chemically altered. His demonic Method acting and Uncle Remus mannerisms rile everyone, especially Alpa Chino (Brandon T. Jackson), the rap star who plays Motown, the other black member of the squad. No doubt the racial stereotypes will anger many in the audience who won’t buy the irony. Call it black comedy.

So Cockburn decides to shake things up by dropping the entire cast into the middle of the jungle and having them act out the movie as if it were a reality TV show. Actual reality intervenes, of course, and the boundaries between what’s real and what’s make-believe blur and become meaningless. Sounds predictable and academic, but what’s unexpected is how deftly Stiller manages to explore these issues and allude to war films from The Bridge on the River Kwai to Platoon to Rambo while still recognizing the value of a well-placed fart joke.

There should be some kind of award for that. And for the film’s uncanny eye for the bizarre detail, such as the musk ox in the frame with Downey during a heartfelt monologue, or the hairy wrists and scaly skin of Cruise’s Grossman. Kudos also to Brandon Soo Hoo, who plays the 12-year-old warlord of the Flaming Dragon drug army. His thespian advice to Speedman holds true for Stiller when the film bogs down in earnestness or exposition: “More stupid!”