A few years ago the renowned chef Ferran Adrià presented diners at his restaurant, elBulli, with a simple dish of bright-orange caviar—or rather what looked like caviar: when the guests bit into the orbs, they burst into a mouthful of cantaloupe juice. Since that legendary bit of culinary trompe l’oeil, Adrià and other avant-garde chefs have created many more otherworldly dishes, including mussels that Adrià encases in transparent globes of their own juice.

Eating these spherical foods can evoke childlike joy as you roll the smooth balls around your mouth and explode them with your tongue. But making such confections is not so simple; a lot of chemistry goes into the process.

Chefs have developed two ways to go about it: direct and reverse spherification. Both methods exploit the fact that some gelling mixtures do not set unless ions, charged molecules, are present.

In the direct approach, the chef blends the food into a puree or broth that contains a gelling agent, such as sodium alginate or iota carrageenan, but that lacks coagulating ions. The cook separately prepares a setting bath that contains a source of the missing ions, such as calcium gluconate. As soon as droplets or spoonfuls of the food fall into the bath, gelling begins.

Surface tension pulls the beads into their distinctive round shape. A short dip in the bath yields liquid-filled balls encased in tissue-thin skin; a long soak produces chewy beads. The cook stops the gelling process by rinsing the beads and heating them to 85 degrees Celsius (185 degrees Fahrenheit) for 10 minutes.

Reverse spherification inverts the process: calcium lactate or some other source of calcium ions is added to the edible liquid or puree—unless the food is naturally rich in calcium. The bath contains unset gel made with deionized or distilled water, which is calcium-free. When the food goes in, the bath solution itself forms a skin of gel around it. The culinary team at our lab has used spherification to make marbles of crystal-clear tomato water that enclose smaller spheres of basil oil. We have also found that this technique is a terrific way to make a very convincing-looking raw “egg” out of little more than water, ham broth (for the white) and melon juice (for the yolk). It tastes much better than it looks.