Glee - Neil Patrick Harris, Joss Whedon, Matthew Morrison Glee - Neil Patrick Harris, Joss Whedon, Matthew Morrison

Joss Whedon was an obvious choice to direct an episode of Glee. The Buffy the Vampire Slayer creator loves high school TV shows and musicals, but the show gave him an added motivation: the chance to reteam with Neil Patrick Harris, the star of his Internet hit Dr. Horrible's Sing-Along Blog.

"I am so tired of that guy. Why do they always make me direct Neil? Why the pain," Whedon joked with reporters on a recent conference call. "Neil is a consummate pro and a dear friend, which is an ideal combination. ... We had so much fun."

Wait for it! Neil Patrick Harris to guest on Glee

In the episode, airing Tuesday at 9/8c on Fox, Harris plays Bryan Ryan, a former McKinley High glee club star and the arch-rival of Will Schuster (Matthew Morrison). After failing to achieve his dreams of super stardom after graduation, Bryan returns, intent on getting revenge on the group that he believes led to his downfall.

"The sort of rivalry/affection between them just informed the whole thing so much," Whedon says of the dynamic between the How I Met Your Mother star and Morrison. "I think you can see there's a little bit of a Western element in there. That really came from the music, but then it ended up in forming more of the show, I think, of how these guys face off against each other."

Watch full episodes of Glee

In the episode, entitled "Dream On," three of the series' main characters confront their past, present and future goals as Bryan attempts to avenge his broken dreams.

"With Will, it's his desire to perform and what he may have given up. With Rachel, its questions about who her real mother was, and Artie obviously thinks about if he'll ever one day get out of the chair," Whedon says. "These are very, very hard personal things that they don't necessarily talk about with other people. I was really lucky because there's a real fantastic coherence to the episode that really brought them all together on an emotional level."

Joss Whedon tapped to direct Avengers movie

Whedon's previous work with Harris on the 2007 web series Dr. Horrible helped in several ways. "Doing Buffy and doing Dr. Horrible were both great prep for something like this. This is obviously not my first rodeo," Whedon says, also referring to Buffy's 2001 musical episode, "Once More, with Feeling." "It's the kind of thing that I would like to spend a lot more of my time doing. I love musicals deeply and dearly. This was a return to home for me."

After serving as creator and executive producer on Buffy as well as Angel, Firefly and Dollhouse, it was "tricky" for Whedon to direct someone else's series, Whedon says.

 "You're living in somebody else's house and you have to make sure that you're fulfilling their needs. It also takes some of the burden off you. You don't have to be the guy who sees the big picture," he says. "Having said that, Glee is probably harder to shoot than any other show in recorded history, with all the different elements going on and whatnot; it's a different kind of challenge, but ultimately enormous fun."

Though he's busy with other projects, Whedon won't rule out a second time behind the camera on Glee. "If I had the window and they would take me, yes, in a heartbeat," he says.