The scene: Los Angeles, 1970.

The characters: a hippie private eye; his imperiled ex-girlfriend; a Los Angeles police detective who longs for celebrity; a musician and snitch who’s supposed to be dead; a supposedly straight deputy D.A. who spends her evenings with the pot-smoking hippie private eye; and many more.

In “Inherent Vice,” director Paul Thomas Anderson, whose previous explorations of places and people in time include “There Will Be Blood,” “Boogie Nights” and “Magnolia,” presents a dreamy trip to the end of the 1960s. Based on a Thomas Pynchon novel and thick with colorful characters, the story mashes together ’40s and ’50s film noir and ’60s psychedelica into an initially dense, ultimately frothy yet enjoyable cinema excursion.

Joaquin Phoenix leads the deep ensemble cast as private detective Doc Sportello. Doc’s ex-girlfriend, Shasta, makes a surprise visit to his Gordita Beach home. Shasta, now a real estate billionaire’s girlfriend, is unavoidably entangled with the billionaire’s wife and her lover.

After the billionaire’s wife and her lover ask Shasta to join them in a scheme to commit the real estate kingpin to a mental hospital, Shasta asks Doc for help. He listens closely and quickly gets to work, investigating Shasta’s paradoxical lover. Mickey Wolfmann, a Jew, surrounds himself with Nazi bikers.

For Doc, it’s going to be a long, strange investigation. Besides his inquiry’s frequent bouts of weirdness, Doc experiences soulful moments of poignancy. He still loves the elusive Shasta. Phoenix drifts smoothly into his character’s occasional, lyrical episodes of bittersweet introspection. He’s among the screen’s most contemplative actors.

Doc, unless he’s going undercover, dons the counterculture style that was mainstream by 1970. His face, too, is partially covered by the then common mutton chop sideburns. Sleuthing about L.A., he ponders and smokes his way through his quest for clues and answers, worrying about Shasta all the way.

Phoenix, previously seen as the substance-abusing Freddie Quell in Anderson’s cult-inspired drama “The Master,” charts a lighter course in “Inherent Vice.” Anderson sets a comic, offbeat tone, occasionally heightened by farcical episodes.

Although Doc makes irreverent work of an interrogation by FBI agents who attempt to intimidate him, he has a truly worrisome foe in Lt. Det. Christian F. “Bigfoot” Bjornsen. Josh Brolin co-stars as an archetypal ’60s, counterculture-hating cop, straight out of Jack Webb’s classic TV show, “Dragnet.” A flattop and regimental dark suit reinforce Bigfoot’s anti-Doc agenda.

Bigfoot doesn’t hesitate to use his big foot on, for instance, Doc. But the cop’s and hippie detective’s relationship isn’t all that simple. Brolin more than justifies his casting in the plum character role of Bigfoot. He lurches through a tongue-in-cheek, scene-stealing performance as this ludicrously bad cop. For comedy’s sake, Doc and Bigfoot play badly together. Phoenix makes a fine straight man for Brolin’s nutty police detective.

Actors obviously want to work with Anderson. At 44, this American film master is in his prime. Oscar winners Reese Witherspoon (“Walk the Line,” “Wild”) and Benicio Del Toro (“Traffic,” “The Usual Suspects”) play lively supporting roles in “Inherent Vice.” Owen Wilson makes subtly comic appearances as a saxophonist-informant and Martin Short rips through bizarre comic sequences as a mad dentist.

Even the film’s smaller roles, including Eric Roberts as Wolfman, Michael Kenneth Williams as a black radical and Maya Rudolph as Doc’s wryly discreet secretary, Petunia Leeway — thoroughly engage.

The film’s musical score by Radiohead’s Jonny Greenwood — it sounds like Doors outtakes, recorded while Jim Morrison was too high to sing — also helps Anderson set the late ’60s, L.A. vibe.

Anderson masterfully translates Pynchon’s characters and situations to the screen. It’s as close to being present in that bygone melieu, or having been there, as many of us are likely to get.