Nuclear fusion, luminescence, fluorescence, bioluminescence and combustion all produce light. In terms of astronomy, high-energy photons are given off when hydrogen nuclei fuse together to form helium, a heavier element, in the core of the sun. Gamma rays are given off during this reaction, and these photons take 1 million years to reach the surface because of the sun's convection layer that constantly reabsorbs photons.
The reason nuclear fusion works is that some of the hydrogen's mass is converted to energy, described in Einstein's famous equation E=mc^2, in which the energy produced is equal to the mass times the speed of light squared. A lot of energy is produced in just a small amount of mass. Sunlight emitted by the surface of the sun is about 230 million watts per square yard, and about 1 millionth of that energy reaches Earth.
Combustion gives off energy in the form of heat and light, which humans typically see as a flame. Hydrocarbons such as methane, ethane, or wood combine with heat and oxygen to produce carbon dioxide, water, heat and light. Energy is given off when molecular bonds are rearranged in a combustion reaction.
Bioluminescence occurs when chemical reactions in living beings emit light. Less than 20 percent of the light produced by living beings gives off heat. Most bioluminescent organisms live in the ocean, and these life forms require luciferin and luciferase or photoprotein to create light.
In general, light is created when subatomic particles, called photons, switch between energy levels in atoms. This often happens in radioactive materials and under very high temperatures.