Bioluminescence occurs through a chemical reaction that produces light energy within an organism's body. For a reaction to occur, a species must contain luciferin, a molecule that, when it reacts with oxygen, produces light. There are different types of luciferin, which vary depending on the animal hosting the reaction. Many organisms also produce the catalyst luciferase, which helps to speed up the reaction.
Animals can closely control when they light up by regulating their chemistry and brain processes depending on their immediate needs, whether a meal or a mate. Some organisms even bundle the luciferin with oxygen in what is called a “photoprotein”—like a pre-packaged bioluminescence bomb—that is ready to light up the moment a certain ion (typically calcium) becomes present. They can even choose the intensity and color of the lights.