For decades, scientists have known how birds with yellow or red feathers usually get their color: It comes from pigments in foods the birds eat. Flamingoes, for instance, extract pink pigments from algae and crustaceans they filter out of the water. The challenge has been to figure out exactly how blue birds get their color. It can’t be their diet: blue pigments, like those in blueberries, are destroyed when birds digest them. Scientists theorized that birds look blue for the same reason the sky looks blue: Red and yellow wavelengths pass through the atmosphere, but shorter blue wavelengths bounce off of particles and scatter, emitting a blue glow in every direction.

Richard Prum, an ornithologist at Yale, discovered that birds make blue feathers in a different way. “Let’s look at some birds!” he says as he pulls out a drawer full of the sewn-up skins of various species of cotingas, birds that live in Central and South America. At first they all look like pretty blue birds with black marks. But look closer, and the different species have slightly different shades of blue.

To find the origins of avian blue, Prum and his colleagues have analyzed hundreds of feathers—from representatives of almost every group that evolved blue coloration—at the Argonne National Laboratory in Illinois, where particle accelerators generate extremely strong X-rays.

Prum discovered that as a blue feather grows, something amazing happens. Inside each cell, stringy keratin molecules separate from water, like oil from vinegar. When the cell dies, the water dries away and is replaced by air, leaving a structure of keratin protein interspersed with air pockets, like a sponge or a box of spaghetti. When white light strikes a blue feather, the keratin pattern causes red and yellow wavelengths to cancel each other out, while blue wavelengths of light reinforce and amplify one another and reflect back to the beholder’s eye. The result: blue, an example of what scientists call a structural color (as opposed to a pigmented color) because it’s generated by light interacting with a feather’s 3-D arrangement. And different shapes and sizes of these air pockets and keratin make different shades of blue.

Building such precise nanostructures is an exceptional evolutionary feat of engineering, yet the color blue has popped up independently on many different branches of the bird family tree, especially in males. Which raises the question: Why? One theory is that a set of fine blue feathers signifies a healthy, well-fed male, advertising his good genes to potential mates. “This is like match.com, complete with how much money you have in the bank, who your family was, religion, do you have sexually transmitted diseases—all these practical things,” Prum says. But he thinks biologists have gone too far with the idea that male ornaments, such as antlers or wattles, are signals to females. “I think that can be true, but that it’s mostly not true,” he says; perhaps they are “merely beautiful.”

What if birds, like humans, have a sense of beauty? Rather than being cold, calculating egg-laying machines, what if female birds just like pretty boys? Prum has been teaching a class called “Evolution of Beauty” and is working on a theory that combines evolution and aesthetics; he thinks physical beauty in animals evolves along with attraction to it. Prum collaborates with philosophers, mathematicians and physicists; his willingness to think across disciplines was part of what won him a MacArthur Fellowship, or “genius grant,” a few years ago. He’s using the highest tech tools to study an age-old question. “It’s simultaneously about physics, et cetera, but it’s really about, What do females want? It’s really about beauty.”