The speed of light depends on the density of the medium. The animations on this page show how the density affects how light rays or light wave fronts behave when the density along its path changes, both for sudden changes (Snell's law) and density gradients (Fermant's principle).
In the animations, the more dense an area is, the lighter blue it appears. Black means a density of 0 (vacuum). Densities are given relativ to a mean density in the range of ±1.
Move the Ligthray slider to watch how a light ray wave front is refracted due to different speeds of light in different densities.
Notice how a vertical density gradient as it exists in the atmosphere causes light to bend at a certain radius of curvature. The bending is often related to the radius of the earth and expressed in the refraction coefficient
For more Infos about atmospheric refraction see: