Light formed by the sun? This is an extract from the astrophysics chapter in my book:

Hydrogen atoms fuse to form helium.  At the same time, lots of of gamma photons and neutrinos are produced. The photons take thousands of years to "fight" their way to the surface of the Sun, but then escape into space as visible or near visible photons at the speed of light.

I am really confused about how the sun produces light. I understand that through nuclear fusion, energy is formed, but isn't this energy in the form of thermal and gamma photons? I do not understand how visible light is emitted which is the reason to why we see the sun. Could someone please elaborate the paragraph from my book.
 A: Hydrogen atoms fuse to form helium through the proton-proton chain which fuses four protons into one alpha particle (nucleus of ${}^{4}He$) and releases two neutrinos, two positrons and energy in the form of gamma photons. Although photons travel at the speed of light, the random motions they experienced inside the sun takes them thousand of years to leave the Sun' center. This random motion is due to the dense plasma in the Sun's interior since each photon permanently collides with an electron and gets deviated from its original path. The Energy released by fusion moves outward up to the top of the radiation zone, where the temperature  drops to about 2 million K, then the photons get absorbed by the plasma more easily and this creates the necessary conditions for convection. This creates the convection zone of the zone. Then the plasma rises and the photons are carried to the photosphere where the density of the gas is low enough that they can escape. They mostly escape as visible photons, as their initial energy is lost through the random motion in the radiactive zone, and the absortion in the convective zone.
A: The photons we see are the result of black body radiation. The light from the Sun is emitted by basically the same process that emits light from an incandescent light bulb.
The energy released by fusion at the core is rapidly randomised as photons interact with the charged particles in the plasma, and you end up with just a hot plasma. The heat is gradually transferred outwards and ends up as a surface temperature of about 5800K. I won't go into the mechanism of black body radiation because this is addressed in the answers to the question What are the various physical mechanisms for energy transfer to the photon during blackbody emission?. Suffice to say that the thermal motion of charged particles in the plasma cause random oscillating electric dipoles, and these then emit electromagnetic radiation corresponding to the energy of these oscillations. Because the oscillations are random the result is emission of a broad spread of wavelengths with a peak at about 500nm.
A: The essence of your question seems to be:

"... isn't this energy in the form of thermal and gamma photons? I do not understand how visible light is emitted which is the reason to why we see the sun.".

The Sun is a large ball of matter that is undergoing a thermonuclear reaction - like a flask of chemicals reacting with each other to create new chemicals and light except it's not a chemical reaction it's a nuclear reaction (like looking at a large Nuclear Reactor with no walls and a much more complicated series of reactions; a lot of different kinds of fuel).
Here is the series of reactions that occur:

4 (1H) ------> 4 He + 2 e+ + 2 neutrinos + energy
3 (4He) ------> 12C + energy
12C + 12C ------> 24Mg + energy
12C + 4 He ------> 16O + energy
16O + 16O ------> 32S + energy
16O + 4 He -----> 20Ne +energy
28Si + 7(4 He) ------> 56Ni + energy
56Ni ------> 56Co + e+ (postive Beta Decay)
56Co ------> 56Fe + e+ (positive Beta Decay)
56Fe + n ------> 57Fe
57Fe + n ------> 58Fe
58Fe + n ------> 59Fe

That's what makes the Sun burn or fuse, those are the formulas of the nuclear reactions occurring in the Sun.
Source: https://imagine.gsfc.nasa.gov/educators/lessons/xray_spectra/activity-fusion.html .
That is called Stellar nucleosynthesis, the process by which the natural abundances of the chemical elements within stars change due to nuclear fusion reactions in the cores and their overlying mantles.
Cross section of a supergiant showing nucleosynthesis and elements formed.

Now we have the 'light engine' running we next describe how visible light is produced (from the Sun). 

Side Note: Your question suggests that the Sun (our Sun) must produce light for us to see it, of course that is not true, light from other Stars could reflect off of a dark ball and we could see the Sun (our Sun) after it is extinguished (though it is unlikely that we (Mankind) would be alive and inhabiting this area) - but we wander far from the question now.



Back to your question: "I do not understand how visible light is emitted ...".

Source for this answer: https://imagine.gsfc.nasa.gov/educators/gammaraybursts/imagine/page7.html .
Light is the familiar word for what physicists call electromagnetic radiation or electromagnetic waves. Light is a form of energy; it can travel through empty space and is in the form of individual wave packets called photons. The waves in packets of visible light are tiny ripples less than a millionth of a meter long. 
When visible light is split up into its different wavelengths, the result is called a spectrum. Violet light has the shortest wavelength and red light has the longest — about twice as long as violet. Visible light is not the only form of electromagnetic radiation, however. The electromagnetic spectrum extends beyond the colors of the rainbow in both directions — to much shorter wavelengths than the violet and to much longer wavelengths than the red. At the longer wavelengths are radio waves, microwaves, and infrared radiation. At the shorter wavelengths are ultraviolet radiation, X-rays, and gamma-rays.
It is important to know that the Sun is not a Lambertian radiator (a circular disk of evenly emitted light). The Sun is not spherical but is instead described variously as a flattened disk, a quadrupole or a hexadecapole shape. Because it is mostly gaseous and liquid, with a solid core, each onion ring layer rotates at a different speed as does each latitude; this means different intensities of different wavelengths are emitted from different portions at different times, in both short period (minutes) variations and 11 year cycles - also sunspots and prominences alter the intensity of light at various wavelengths (black sunspots are cooler and brightly emit X-rays and high-energy particles).
Shape of the Sun:

More information: Using Precise Solar Limb Shape Measurements to Study the Solar Cycle - By: J. R. Kuhn, L. E. Floyd, Claus Fröhlich, et. al. - Jan 2000.
In addition the brightness is affected in a more easily visible manner by what is called Limb Darkening (oversimplified that means that the edges of the Sun are thin and can't emit as much visible light as the central portion). A slightly more complicated explanation comes from Wikipedia's Limb Darkening Article, or for Doctoral Astrophysics see H. H. Plaskett's Limb darkening and solar rotation or this more recent (and readable) Article Max Planck Institute Article on Solar Variance.
This is how the intensity varies based on latitudes:

Note that measurement is for a specific range of visible light and does not apply longitudinally. What constitutes lateral and longitudinal on the Sun is determined by the Sun's Axis, which is determined by it's Magnetic Field, which varies with the flow of the undercurrents of the various layers.
In general light is emitted similarly to what a camera records during a Solar Eclipse, this is a grossly oversimplified explanation:

That explains how the light is created (including light, energy waves, that are not visible to the human eye) and how it's intensity varies based on location, angle, time, etc. that it is viewed. The actual color of a Sun is determined by it's temperature, see here for more information on spectrum and color vs. temperature (why are there no green Suns): https://science.nasa.gov/ems/09_visiblelight .
This is the Spectrum of visible light:

This is where visible light occurs within the full Spectrum (of Energy):

To understand the Universe, astronomers look at all wavelengths; the cosmic sky has a totally different appearance at different wavelengths of light. 
At radio wavelengths, astronomers see distant quasars and hot gas in our Milky Way Galaxy. The infrared sky shows mainly tiny dust particles strewn through our Galaxy and other galaxies. Visible and ultraviolet show mainly the light from ordinary stars. X-rays reveal gas heated to millions of degrees lying between galaxies or falling onto compact objects like neutron stars and black holes. Gamma-rays can be produced only by extremely energetic phenomena, and we see several types of gamma-ray emission in the sky.
Gamma-rays seen along the plane of the Milky Way are not from ordinary stars, but from nuclear reactions generated by protons accelerated to nearly the speed of light slamming into gas lying between the stars. Gamma-rays are also seen from blazars -- intense beams of light and particles pointed directly at the Earth produced by massive black holes in distant galaxies. Gamma-rays can be detected in the magnetic flares on the surface of our Sun, and by the radioactive decay of short-lived atomic nuclei produced by supernova explosions in the Galaxy.
All objects in our Universe emit, reflect, and absorb electromagnetic radiation in their own distinctive ways. The way an object does this provides it special characteristics which scientists can use to probe an object’s composition, temperature, density, age, motion, distance, and other chemical and physical quantities. 
...
We can think of electromagnetic radiation in several different ways:
• From a physical science standpoint, all electromagnetic radiation can be thought of as originating from the motions of subatomic particles. Gamma-rays occur when atomic nuclei are split or fused. X-rays occur when an electron orbiting close to an atomic nucleus is pushed outward with such force that it escapes the atom; ultraviolet, when an electron is jolted from a near to a far orbit; and visible and infrared, when electrons are jolted a few orbits out. Photons in these three energy ranges (X-ray, UV, and optical) are emitted as one of the outer shell electrons loses enough energy to fall down to the replace the electron missing from the inner shell. Radio waves are generated by any electron movement; even the stream of electrons (electric current) in a common household wire creates radio waves ...albeit with wavelengths of thousands of kilometers and of very weak amplitude.
• Electromagnetic radiation can be described in terms of a stream of photons (massless packets of energy), each traveling in a wave-like pattern, moving at the speed of light. The only difference between radio waves, visible light, and gamma-rays is the amount of energy in the photons. Radio waves have photons with low energies, microwaves have a little more energy than radio waves, infrared has still more, then visible, ultraviolet, X-rays, and gamma-rays. By the equation E=hf, energy dictates a photon’s frequency and, hence, wavelength.
The value of the EM radiation we receive from the Universe can be realized by considering the following: Temperatures in the Universe today range from 1010 Kelvin to 2.7 Kelvin (in the cores of stars going supernova and in intergalactic space, respectively). Densities range over 45 orders of magnitude between the centers of neutron stars to the virtual emptiness of intergalactic space. Magnetic field strengths can range from the 1013 Gauss fields around neutron stars to the 1 Gauss fields of planets such as Earth to the 10-7 Gauss fields of intergalactic space. It is not possible to reproduce these enormous ranges in a laboratory on Earth and study the results of controlled experiments; we must use the Universe as our laboratory in order to see how matter and energy behave in these extreme conditions.
...
As suggested, please see: https://imagine.gsfc.nasa.gov/educators/gammaraybursts/imagine/page7.html for the unabridged version.
What you call visible light is based upon a few things, you can see the light because of these three things: it is produced and travels towards you, it passes through the atmosphere without being blocked and your eyes are sensitive to that frequency - some people are more sensitive to UV and IR light than others much as some people can hear higher or lower frequencies.

Note how the Atmosphere creates 'windows' or filters that only allow certain wavelengths to penetrate a certain distance. Only visible light and a particular band of radio frequencies can penetrate all the way to the Earth's surface.
Your Camera and Scientific Instruments on Earth and in Space can 'see' a wider spectrum than your eyes can but those frequencies can be tone-mapped (un-HDR'ed) into images that your eyes can see and your brain might understand (like Radar can provide information to a trained observer, but we can not see radio waves).
See: https://imagine.gsfc.nasa.gov/science/toolbox/spectra1.html for more information.
For more information about the Electromagnetic Spectrum (visible light and the adjacent frequencies) see: https://imagine.gsfc.nasa.gov/science/toolbox/emspectrum1.html .
Additional information on emission of light from the Sun (it's journey from beneath the surface to our eyes) see: How do neutrinos pass through the sun so quickly .
So that's how the Sun creates energy, some we can see with our eyes and most we can detect with instruments (and map to an image), how it travels and why some energy is blocked (preventing severe sunburn). You didn't ask how your eyes convert the energy so your brain can see so I won't go further, but that answer is on SE.
An Online Course from PSU geared towards younger readers is available here: https://www.e-education.psu.edu/astro801/content/l3.html .
