Warning: Spoilers ahead for "Westworld" season three, episode five, "Genre."

In Sunday night's new episode of "Westworld," Caleb was given a drug called Genre which made him experience events as if he was inside of a movie.

Series cocreator Jonathan Nolan explained all the movie genre inspirations in an interview with Insider.

Film noirs were paid homage to with an original Ramin Djawadi score.

"The note was give me something that is the love child of 'Out of the Past' and 'Vertigo,'" Nolan said.

There were also references to "Apocalypse Now," "Trainspotting," "Love Story," "The Shining," and "Willy Wonka and the Chocolate Factory."

Visit Insider's homepage for more stories.

"Westworld" cocreator Jonathan Nolan never passes up the opportunity to pay homage to his favorite sci-fi books, video games, movies, and more. And no episode in the series has encapsulated this penchant for Easter eggs quite in the way Sunday's "Genre" managed.

Caleb (played by Aaron Paul) was given a dose of an illicit drug which made his experiences play out like various movie genres. This concept has a direct tie to the Westworld theme park, and also to various films Nolan loves.

"Westworld" season three, episode five, "Genre." HBO

We spoke with Nolan about the specific references made with each phase of the drug, and how the concept for the drug itself is an homage to "Willy Wonka and the Chocolate Factory" and the "meal-in-gum" candy.

So let's go through the episode genre-by-genre and unpack each movie reference, starting with the black and white film noir.

Caleb's drug trip begins with a film noir reference to 'Out of the Past' and 'Vertigo'

James Stewart in Hitchcock's "Vertigo." Universal screengrab via MovieClips

When Caleb first starts noticing the effects of the Genre drug, his entire perspective goes in grayscale. Nolan says "noir is the strongest influence" in this first sequence. For this genre, the score isn't lifted straight from an iconic movie scene (as is the case for the others), but was written by "Westworld" composer Ramin Djawadi.

"It's a Ramin original, but it's an homage the great scores of the film noir period," Nolan said. "We desaturated the film, left a little bit of the silver in there, and with Ramin's music the note was, 'Give me something that is the love child of 'Out of the Past' and 'Vertigo.'"

"Out of the Past" is a 1947 film noir directed by Jacques Tourneur, and "Vertigo" is Alfred Hitchcock's 1958 thriller of the same genre.

"The music Ramin makes for us in the show is so beautiful," Nolan said. But there are distinct movements in which different timbres and different instrumentation had predominated. One of the things that the episode is really playing on is the idea that cinema is more than 100 years old now, which means everyone in the world — whether they're movie buffs or not — has a little bit of cinema stuck in their understanding of the world around them. And some of the things that cinema has done over the years with music are indelible."

The next genre Caleb experiences is action, and Nolan gives you 'a punch right on the square your nose' with 'Ride of the Valkyries'

Once Caleb, Dolores, and Liam begin fleeing from the would-be assassins on their tail, the drug switches genres and Richard Wagner's memorable music piece "Ride of the Valkyries" starts playing. Nolan says this was "very much" a reference to Francis Ford Coppola's 1979 war movie "Apocalypse Now," in which "Ride of the Valkyries" was used for the film's most iconic scene.

"It's kind of an amazing thing when you can use a piece of music in a movie so effectively that it almost annihilates anyone else's ability to do that," Nolan said.

As another example of this phenomenon, Nolan explained that he and "Westworld" co-creator Lisa Joy had "various moments" in the pilot episode when they "attempted to have it scored with a piece of 'The Beautiful Blue Danube' by Strauss — a piece of music used memorably in Stanley Kubrick's 1968 movie "2001: A Space Odyssey."

"And then we realized that Kubrick just owns that," Nolan said. "And Francis Ford Coppola owns 'Ride of the Valkyries.'"

"Westworld" season three, episode five, "Genre." HBO

At this point, Nolan also explained that the concept for the Genre drug was a nod to "Willy Wonka & the Chocolate Factory," a novel by Roald Dahl which was adapted into the famous 1971 film starring Gene Wilder. As the unhinged genius Willy Wonka is giving children a tour of his factory, he shows them a work-in-progress invention: The three-course dinner gum.

"It's also inspired in part, of course, by 'Willy Wonka and the Chocolate Factory' and the piece of gum which could continue to change and you'd get three courses," Nolan said.

A single piece of gum is meant to transform flavors, giving the consumer the taste experience of eating an appetizer, entree, and dessert. But the final stage had some kinks, which is how Violet turned violet and blows up like a blueberry.

"So here, as Marshawn [Lynch's character] points out, you gotta be careful with that last act," Nolan said. "There's the idea that this experience would have a distinct progression. And that somewhere in there is a [M. Night] Shyamalan movie waiting."

"The idea is that the [Genre] experience would start in the antiquity of genre, and then make its way through the different pieces," Nolan continued. "Some of them are homage and others are more obscure than others. But 'Ride of the Valkyries' is a punch right on the square your nose in terms of the way that we understand giant pieces of movie music and the way that they make us feel."

Before Caleb gets to his horror movie experience, though, he has to encounter two other genres.

The next two genres, romance and drama, pay tribute to 'Love Story' and 'Trainspotting'

"Westworld" season three, episode five, "Genre." HBO

After "Ride of Valkyries" fades out, and Dolores and Caleb are left standing in the middle of a Los Angeles street with two guns, the genre he's experiencing switches to romance and we hear the score from the 1970 movie "Love Story."

"With 'Love Story,' there was no more iconic piece of romantic music than that score," Nolan said. "And we looked. It's a beautiful piece of music. There are pieces of music that I associate with [romance] more, personally. But you would play that for everyone, of a certain age I suppose, and there's an instant connection."

"One of the things I love about movie music, and music in general, is how it's like a secret trapdoor into people's minds," Nolan said. "That's one of the reasons we use popular music in the show. You get to sneak in there and start pressing buttons, because all these pieces of music have associations for people. With the movie music, it connects you to a shared experience. Something that everyone understands. Lots of people may not have seen ['Love Story'], but the feeling is there."

"Love Story" is one of the highest grossing movies of all time. Paramount

"One of the things I'm fascinated with about music is [how] there's also something beyond that shared experience in the language of music," Nolan said. "The minor key, the major key, the way that it makes everyone feel the same way, largely speaking. That's something we exploit all the time when we're working with Ramin [Djawadi] on a piece of music for a moment. We'll literally describe for Ramin, 'I want this piece of music to make you feel slightly surprised, but also slightly optimistic.' That's a set of notes. There's a chord that does that. I'm fascinated by that."

After the "Love Story" music fades, and Caleb gets snapped out of his goo-goo eyes for Dolores, the group head down into a train station and the genre switches again.

For the first time in his drug trip, Caleb hears a song with lyrics: "Nightclubbing" by Iggy Pop.

"Westworld" season three, episode five, "Genre." HBO

The 1977 tune, co-written by David Bowie, was famously used in the 1996 movie "Trainspotting." It makes sense that Caleb's switch to the drama genre (onboard a train) would be a reference to this seminal drug-trip movie.

The final genre, thriller/horror, uses the score from 'The Shining'

After a brief interlude with reality (over which an instrumental cover of "Space Oddity" by David Bowie plays), Caleb enters the final genre when he and the group walk along the beach in Santa Monica. We hear the score from Stanley Kubrick's 1980 film adaptation "The Shining" — which itself is a rendition of the "Dies Irae" portion of "Symphonie fantastique" by 19th-century French composer Hector Berlioz.

Stanley Kubrick directed "The Shining," an adaptation of the Stephen King novel of the same name. The Fox Is Black

With this film reference, Caleb makes the jump to the '80s, rounding out the drug experience with Liam dying in a bloody mess on the beach. In total, his trip charted about 50 years of movie references.

The entire concept of Genre traces back to the concept of "Westworld" itself; the idea that in the future people would find entertainment in a recreation of the 18th century Wild West.

The Genre drug is just a cheaper alternative to actually visiting one of the Delos Destinations theme parks

Logan and William were wealthy enough to be able to visit Westworld when it first opened. John P. Johnson/HBO

"The lovely thing about our show is that, from the beginning, it's always been about a balance of all the other themes and riffing on film, video games, and television," Nolan said. "And the way in which they intersect with our understanding of the world. The show is playing very explicitly with the idea is that, over the course of the next 50 years as we explore various different levels of reality (one of which is filmmaking itself), people would try to turn their memories of great Westerns of years past into a theme park that they could live in."

As our timeline of the events of "Westworld" shows, the Delos Destinations parks were first started when Dr. Robert Ford (Anthony Hopkins) and Arnold Weber (Jeffrey Wright) created the hosts and then Westworld.

Only after investors from Delos came in did the other parks (Shogun World, War World, etc.) get created. Now there are a total of six parks that the ultra-wealthy can visit.

"It's building out of a post-scarcity society in which many a material needs are met, so it becomes about a search for meaning, the idea that people would want to inhabit [that world]," Nolan said. "They wouldn't be satisfied with spending two hours every six months in the Marvel Universe or in a Western or in a film noir — but they would want to live in one."

Teddy and Dolores as hosts inside the Westworld park. John P. Johnson/HBO

"The park is one expression of that, but the park is very expensive," Nolan continued. "So [Genre] is for regular folks in the world who can't afford to go to the park."

As Nolan points out, Westworld and the other Delos parks aren't accessible to just anyone. A daily visit to the park starts at $40,000 per day, with vacation packages that total up to $6 million.

So what does everyone else do? Take drugs like Genre.

"Since the dawn of time, since the first person accidentally cooked the first leaf that made them feel peculiar, people have been using pharmacology and psychopharmacology to tweak their experience," Nolan said. "It's like umami for life, right? You're just trying to make things a little more bearable or interesting or exciting. And the idea is that, as we get more sophisticated with our ability to manipulate your experience, taking a drug that makes your life feel like you're in a movie is a fairly cheap alternative to going a place like Westworld."

"Westworld" season three continues next Sunday at 9 p.m. ET on HBO.