Bioluminescence is used for luring prey (as in anglerfish), scaring off predators (as in railroad worms), attracting mates (as in fireflies), and even camouflage (photophores in benthic creatures like some deep-sea squids).
Various mechanisms can be used to produce bioluminescent light. A well-known one is the enzyme luciferase, which is frequently used in genetic engineering as a tracer.
Compare to: biofluorescence