As every grade-school kid will confirm, chameleons are special because they can change color. But how these little critters pull off their magic act has always been a little fuzzy. For a long time, scientists thought the color change—which only occurs in males—was controlled by pigment-containing organelles. But it turns out the mechanism actually has more in common with physics and nanomaterials than with biology: It’s driven by a set of tiny crystals embedded in the reptiles' skin.

Studying male panther chameleons from Madagascar, a cross-disciplinary team of biologists and physicists from the University of Geneva found that the reptiles' skin is covered by a thick layer of light-reflecting cells called iridophores, which are embedded with photonic crystals—a latticed organization of guanine nanocrystals. Depending on how closely those crystals are clustered, they reflect different wavelengths of light. The effect is like "an oily spill on the surface of water,” explains University of Maryland physicist Igor Smolyninov, who was not involved in the study. “It appears to have all kinds of colors. The color is defined by the thickness of the layer of oil on water, and a very similar effect occurs in photonic crystals." Watch them in action:

The camouflaging color humans see results from the interaction of those crystals with the native pigment in the chameleon’s skin. When a chameleon is relaxed, the nanocrystals in the iridophore cells cluster together, creating optical interference and reflecting short wavelengths like blue. Because the skin contains yellow pigments, the blue and yellow combine into green, helping the reptile hide from predators. But when the chameleon is excited—like when a male is fighting other males or courting females—the distance between nanocrystals increases, reflecting longer wavelengths (like yellow, orange, or red) and creating different color combos with the underlying yellow pigment.

It actually turns out that there are two kinds of iridophores in chameleons. Superficial S-iridophores, found only in mature male chameleons, are the ones that alter the spacing of nanocrystals to cause rapid color change. But a second set—deeper, D-iridophores—reflect a broad spectrum of light closer to infrared wavelengths. Geneticist Michel Milinkovitch and his team concluded these D-iridophores may play a role in chameleons' internal temperature control by reflecting a significant amount of infrared radiation. That could help explain why chameleons beat the heat for longer durations than other lizards.

Milinkovitch thinks the new research could help point out a natural method for developing materials, fabrics and surfaces change color in response to external stimuli. Smolynoniv points out that the technology could be developed in a way that allows for more efficient detection of specific materials, like blood sugar in diabetics or oil spills in the ocean. But the biggest application could be for structures and clothing that are designed for better thermal regulation and energy efficiency, or camouflage. Every third-grader's dream come true.