In the age of HBO's "The Deuce," "Boogie Nights" looks like a time-honored masterpiece, but when the sprawling period epic about the golden age of porn filmmaking opened 20 years ago this week (on October 10, 1997), moviegoers didn't exactly embrace it.

The subject matter was still too skeevy to draw mainstream or even art-house audiences, yet not nearly explicit enough to draw the trench coat crowd. "Most people don't share my moral sense," writer/director Paul Thomas Andersonexplained in 1999, "which is, 'I'll masturbate, but I have to clean it up very quickly afterwards.'" No wonder "Boogie Nights" wasn't exactly a hit.

Nonetheless, it earned three Oscar nominations, made a serious leading man out of Thomas Jane.

These days, "Boogie Nights" evokes double nostalgia, both for the disco 1970s, lovingly recreated in the movie's costumes and soundtrack, and for the 1990s, when Hollywood studios still nurtured indie directors and let them realize their visions instead of plucking them fresh from Sundance and asg them to direct CGI blockbuster franchise sequels.

"Boogie Nights" had a famously fraught production history, including some life-imitates-porn moments and a near-fistfight between Reynolds and Anderson. Here are some of the things that, uh, went down.
1. Anderson (above, right) grew up in the Valley and was, as a teen, obsessed with the porn industry existing all around him. He was still in high school when he made his first movie, a 32-minute short called "The Dirk Diggler Story," a "Zelig"-like mockumentary about a fallen porn star. In addition to the protagonist, several other characters and much of the dialogue would find their way into "Boogie Nights" a decade later.

2. The Dirk Diggler of Anderson's "Boogie Nights" screenplay bears a strong resemblance to legendary porn actor John Holmes, and not just in of length. There's Holmes' rise to fame via the series of "Johnny Wadd" thrillers (echoed in Dirk's "Brock Landers" movies), his biographical documentary directed by a colleague ("Exhausted," the inspiration for the movie that Hard Eight," they thought he might be it. They decided the director's phone-book-sized script about a guy with a 13-inch penis was edgy enough, as long as he agreed to keep it under three hours and keep the rating down to an R.

4. Anderson initially wanted Sydney Pollack.

6. Samuel L. Jackson, who'd played the villain in "Hard Eight," turned down the role of Buck Swope, the porn actor who dreams of selling stereos. His response to the script, Anderson recalled, was "What the hell is this?" After Moore vouched for the young director, Cheadle took the part and turned it into a career-boosting showcase.

8. There were a number of real-life porn actors in the cast, mostly as extras, though Nina Hartley had the biggest part as the emasculating wife of Little Bill (Heather Graham (Rollergirl) seldom took off her skates, even when cameras weren't rolling.

10. Speaking of penises, the movie's most famous special effect was the prosthetic Diggler that Wahlberg shows off in the final scene. The first one that the make-up team built was John Holmes-sized, but it just looked too huge to seem real, so they built a shorter one, still large enough for Marky Mark to hide his actual funky bunch inside.
11. In fact, the make-up artists built several, in case of breakage. Wahlberg also whipped it out during the sequence where Dirk and Amber are shooting a sex scene; it doesn't appear on camera then, but Wahlberg wanted to get a rise out of Moore. Most of the time, however, the package shown straining against the confines of Dirk's bellbottoms is just a woman's stocking filled with birdseed. The propmakers left the stocking in a warm trunk, where its seeds started to sprout, so they had to make another one.

12. During one scene where Little Bill grumbles about having caught his wife being sodomized by another man, Macy repeatedly muffed his line and said it backwards: "My f**king wife has an ass in her c**k." Anderson decided he preferred the mistake and kept it in the film.
13. While Anderson allowed Macy and others to ad lib, he insisted that Reynolds stay on script. Reynolds became irked and felt that the relatively inexperienced director wasn't giving him the respect he deserved as a veteran movie star. The two men argued loudly, and Reynolds swung a fist that might have hit Anderson in the face had a crew member not held back his arm.

14. Why is Molina the only actor in his scene not distracted by the firecrackers going off at random intervals? Because he's wearing a hidden earpiece piping in "Sister Christian" on a continuous loop.
15. If the song "You Got the Touch," which Dirk records during his dubious effort to branch out into music, sounds familiar, it's because it originally appeared on the soundtrack of the first "Transformers" movie -- the 1986 cartoon, that is. Dirk's other song, "Feel the Heat," was composed by Anderson and Reilly.

16. Avant-garde satirical film director Robert Downey Sr. (yep, Iron Man's real-life dad) shows up in a cameo as the record label executive. With Downey's permission, Anderson cribbed the kid setting off firecrackers from Downey's 1969 movie "Putney Swope," as well as Buck Swope's last name.
17. Anderson had to submit the film to the MPAA 18 times, cutting a few frames each time from scenes the ratings board found too risqué, in order to avoid an NC-17 rating and earn the R rating he was contractually obliged to deliver. In the end, the difference between NC-17 and R turned out to be only 45 seconds worth of film. "I don't miss it at all," Anderson said of the snipped footage.

18. Still, Anderson's cut was over three hours long, making both test audiences and executives at New Line restless. Studio co-founder Bob Shaye made his own two-hour cut of the film and screened it for a test audience in Pasadena. Before the screening, the then-unknown director walked among the viewers in line and bad-mouthed his own film, saying, "This movie sucks. You're gonna hate it. This movie sucks," so that Shaye's cut would earn even lower test scores than his own. Eventually, both sides reached a compromise, resulting in a 155-minute release. Among the lost scenes: Dirk learns his parents have been killed in a gruesome car crash, which is then briefly shown on screen.
19. "Boogie Nights" reportedly cost $15.5 million to make. It earned back $26.4 million in North America and another $16.7 million overseas.

20. The Academy nominated "Boogie Nights" for three Oscars: Best Original Screenplay, Best ing Actress (Moore), and Best ing Actor (Reynolds). It was shut out of all three categories.
21. In 2015, Reynolds Magnolia." "I'd done my picture with Paul Thomas Anderson, that was enough for me," he said. Wahlberg, who recalled Reynolds trying an Irish accent for his role in rehearsals, said in 2014 that he believed Reynolds' evident ill will toward what could have been his career comeback role had consequences. "He would have won the Oscar," Wahlberg said, "had he not dug such a hole for himself."