SAN DIEGO — “It’s just unabashed,” Justin Timberlake says about the Comic-Con experience. He’s there this week for his second-ever trip to the geek confab, after touring the festivities incognito as Ernie from “Sesame Street” when he was there to promote the film “In Time” five years ago. “Where else can you find Gandalf and a Stormtrooper having a beer? They go hard here.”

This time he’s among the consumer masses to pitch DreamWorks Animation’s “Trolls,” releasing Nov. 4. A cheery musical wrought with colorful, tactile-like craftsmanship, the film manifests a mythology behind the ubiquitous creature dolls originally created by Danish woodcutter Thomas Dam: The trolls live a deliriously happy existence, singing on cue, taking breaks throughout the day to hug. They are hunted, meanwhile, by a monstrous race called the Bergin, who get their own happy highs by eating the trolls.

The 35-year-old Timberlake voices Branch, a troll that has grown weary of his community’s overt state of cheer, mostly because it attracts the Bergin. He has become so cantankerous as to see his bright skin and hair tone drained to muted colors. He’s taken on something of a survivalist’s existence, focused on just one thing: defending against a Bergin attack. When that moment comes, the plot sends Branch and bubbly Poppy (Anna Kendrick) off on their way through a vibrant, trippy environment.

The movie has a shot at big business when it opens in the fall, particularly as audiences flock to feel-good toons in the midst of dire world conditions. That dark climate was very much a part of the DreamWorks panel discussion Thursday at the San Diego Convention Center.

“The world right now is a cynical toilet,” moderator Chris Hardwick said. “There’s one convention right now that I’m excited to be at — the other one, not so much,” he continued, indicating the ongoing Republican National Convention in Cleveland.

Director Mike Mitchell took Hardwick’s cue, noting that “the news is depressing. We were really excited to make a film that would make people happy and feel good.”

And that meant the music, too. In addition to voice acting, Timberlake was also tasked with producing the film’s soundtrack, which features re-workings of artists like Earth Wind & Fire, Simon & Garfunkel, Gorillaz and Cyndi Lauper. Not only that, but he also wrote original songs for the film, including “Can’t Stop the Feeling,” which enjoyed a week at the top of the charts last month. Timberlake says the upbeat track, reminiscent of the late-’70s disco-punk confluence, was inspired by Michael Jackson, Bill Withers and the Bee Gees.

“I kept bringing up ‘Saturday Night Fever’ with this movie,” he says. “The filmmakers say they were inspired by the two sides of the ’70s, the two different worlds this movie exists in. So I said let’s make a song that sounds like it could be from the ’70s, but make it modern. Nothing was out that sort of sounded like that, and it just felt like it was perfect for the movie.”

For Timberlake it was also a serendipitous time to tackle this kind of material: His son Silas is 15 months old, and while he doesn’t necessarily feel having a child inspires his artistic choices, Timberlake says it definitely informs them.

“I’d be leaving out the whole truth if I didn’t say having him shaped what the song actually is,” he says. “[Having a child] gives you a different insight. It’s like ‘The Matrix,’ man. You open a door and there’s this whole other world on the other side of it. And you look back through the door at the other world and you’re like, ‘What was I doing there?'”

Being back in the studio and having his hands all over a film soundtrack (a personal dream of his) also lit the spark for a new album. He’s been working on a follow-up to his 2013 double album “The 20/20 Experience” ever since “Trolls” came into his life, but he’s approaching it casually.

“I’m kind of taking my time,” he says. “I’m doing the Woody [Allen] movie in the fall, so that was unexpected. I think for the first time in my career I feel like I can slow down and be a little more patient.”

Speaking of the Allen project, which also stars Kate Winslet, Juno Temple and Jim Belushi, Timberlake is abrupt when asked if there was any trepidation in taking on the role, given the resurgence of previous allegations that Allen sexually assaulted his own daughter Dylan two decades ago. “No, I don’t get into that stuff, man,” he says.

Timberlake wants to keep his acting career revved. In particular, he would love to reunite with “The Social Network” helmer David Fincher, who also directed the music video from “Suit & Tie” from “The 20/20 Experience.”

“Whenever he needs me, I am a masochist, and he is very good at being a sadist,” Timberlake says. “I enjoy working with David so much because you go home at night after every day and go, ‘Well, I don’t think we could have tried anything else.’ You really feel like you left it on the floor. I find so much of filmmaking is maddening because you get to the end of principal photography and you go ‘Oh, now I know how to play this role.’ But his level, it’s a different type of meticulous. It’s a one of a kind.”

For now, it’s back into the studio to finish that new album — on his time, at his pace. It’s a downward gear shift he attributes to, what else — getting older.

“Maybe it’s the difference between 20s and 30s,” he says. “The difference between ‘must achieve,’ and now it’s like, ‘Work smarter, not harder.’ You want to have time for your family.”