LOS ANGELES — Pharrell Williams remembers the exact moment when he realized he was ready to return to N.E.R.D, his long-running side project with Chad Hugo and Shae Haley. In the beginning of 2016, he dyed his hair green: “The minute I looked in the mirror, I was like, ‘Oh, starting N.E.R.D now.’”

He had just left Nashville, where he’d been producing and writing on “Wanderlust,” an album by the unflinchingly smooth country group Little Big Town. And he was coming off the peak of his career as a recording artist: “Blurred Lines,” his limber collaboration with Robin Thicke, and “Get Lucky,” his disco revival with Daft Punk, held No. 1 and 2 on the Billboard Hot 100 for a time in 2013; the next year, the pop-gospel hymn “Happy” became his first No. 1 as a lead artist, and the song that vaulted him into the stratosphere.

He wore an artfully goofy hat to the Grammys. He joined “The Voice” as a coach. He sat for an interview with Oprah, and cried. For someone who’d spent much of his career making others sound good as a producer and songwriter, it was a belated, and extremely loud, splash into the brightest spot of the limelight.