Image copyright ALEX HYDE / SPL Image caption The study was conducted on panther chameleons, which are popular pets

Swiss researchers have discovered how chameleons accomplish their vivid colour changes: they rearrange the crystals inside specialised skin cells.

It was previously suggested that the reptiles' famous ability came from gathering or dispersing coloured pigments inside different cells.

But the new results put it down to a "selective mirror" made of crystals.

They also reveal a second layer of the cells that reflect near-infrared light and might help the animals keep cool.

Reptiles make colours in two ways: they have cells full of pigment for warm or dark colours, but brighter blues and whites come from light bouncing off physical elements like these crystals: so-called "structural colours".

These colours can also be mixed. A vibrant green might arise from a structural blue overlaid by yellow pigment.

Image copyright Teyssier, Saenko, van der Marel and Milinkovitch Image caption A panther chameleon can switch in minutes from camouflage colours to more strident, communicative ones

Some changes arise from shifting pigments. Tiny packets of the dark dye melanin, for example, can be spread throughout the tendrils of big "melanophore" cells - or gathered into the centre, to lighten the skin again. Many fish and reptiles grow lighter or darker in this way in response to stress, or to match their surroundings.

[It's] an amazing toolkit that allows them to choose between being hidden or displaying very spectacular colours for communication Prof Michel Milinkovitch, University of Geneva

Panther chameleons, the subjects of the new study, do this as well. But males can also change between entirely different colours, turning a camouflaged green into a more spectacular yellow, for example, when they see a potential mate or a competitor.

Until now, many scientists had thought that these changes arose from a similar dispersion trick with yellow or red pigment. The new research suggests this is not the case.

Loosening lattice

Published in the journal Nature Communications, the study was a collaboration between quantum physicists and evolutionary biologists at the University of Geneva.

First of all, the team noticed there were no big, spidery cells containing yellow or red pigment that could explain the shifts in hue.

They hit upon the importance of the crystals when they looked inside a type of cell called an "iridophore" using an electron microscope. Whichever angle they looked at them from, the crystals formed an incredibly neat, regular pattern - just the sort of arrangement that creates structural colours.

"When you see this with the eye of a physicist, you know it will have an effect on light," said senior author Prof Michel Milinkovitch.

So Prof Milinkovitch and his colleagues set out to establish whether these crystals might explain not just the chameleon's bright colours, but its changes to those colours as well.

Image copyright M Miliknovitch, lanevol.org Image caption The animals are native to Madagascar, where their colours help them blend into the forest

Looking closely at video footage of the colour changes, they saw a pattern (from blue, through green, into yellow and orange) that could not be explained by the pigments available in the chameleon's skin. But when they modelled what changes might be produced by shifting the spacing of the crystals, they found a very close match.

And, crucially, when they compared a tiny piece of "relaxed" chameleon skin with a sample from the same animal when it was "excited" (showing off in front of another male), there was an obvious change in the crystal pattern.

"The net effect is that it will work as a selective mirror," Prof Milinkovitch told the BBC.

"Light will go through except for very specific wavelengths. If the distance between the layers is small, it reflects small wavelengths, like blue; if the distance is large it reflects larger wavelengths - for example, red."

Image copyright M Milinkovitch Image caption Inside the "iridophore" cells of a relaxed chameleon (left) the crystals are tightly packed; excitement causes them to loosen (right)

The researchers also took a sample of skin and showed that if they altered the crystal packing themselves, by putting the cells in salty water to suck the fluid out of them, they could reproduce a colour change just like the one seen on the animals.

We know that other lizards change colour by changing the size and spacing of those crystals - but this is the first demonstration in chameleons Dr Devi Stuart-Fox, University of Melbourne

This is the first time that reptile skin has been shown to change colour thanks to this kind of geometrical shift, Prof Milinkovitch said.

Cool customer

Beneath the layer of iridophores that contained a nice, regular lattice of crystals, the team also spotted an additional layer, where the cells were much bigger and more chaotically organised.

Because that higgledy-piggledy structure reflects near-infrared light particularly well, they believe it might serve to reflect the sun's warming rays and keep the chameleons cool.

This split appears to be unique to chameleons; other lizards tend to have their crystals arranged in a regular way to give bright colours, or a disorganised way that reflects the heat. With their added layer, chameleons manage to combine the two extremes.

Image copyright M Milinkovitch, lanevol.org Image caption An extra layer of cells that reflect near-infrared wavelengths may help chameleons stay cool in the sun

"Chameleons invented something completely new in evolution," Prof Milinkovitch said.

"They split the iridophores into two layers, one that is specialised for colour change... and one to reduce the amount of energy absorbed by the animal.

"That's an amazing toolkit that allows them to choose between being hidden or displaying very spectacular colours for communication - and on top of that they have this ability to control their temperature because of the deep iridophores."

Dr Devi Stuart-Fox, an expert in animal colouration and senior lecturer at the University of Melbourne, told BBC News she was impressed by the Swiss study.

"We know that other lizards change colour by changing the size and spacing of those crystals - but this paper is the first demonstration in chameleons and demonstrates it very convincingly.

"What is really novel about this study is that it shows that there are two layers of these iridophores, not just one. And the crystals in the deeper layer affect not just visible colour but also how the skin reflects the near-infrared - a part of the spectrum of sunlight that neither we nor chameleons can see."

She added that it was "too early to say" exactly what job that second layer is doing for the animal, and more experiments would be required to show that it is providing "passive thermal protection" as the Swiss researchers suggest.

Follow Jonathan on Twitter