Great question, at base level its what the nebula is made of.
In a typical situation the particles in the nebular are excited by background radiation, usually UV from nearby stars. These particles then de-excite and emit light that is unique to the particle themselves.
I’ll add that a lot of images you see are false colour as the spectrum emitted has been massively red/blue shifted or the particles themselves just emit outside of the visible spectrum.
Comments