When a light ray is incident on a boundary between an optically denser medium μ₁ and a lighter medium μ₂, then total internal reflection can occur.
Refractive index μ of a medium gives the optical density of the medium.
Let the light rays pass from the optically denser medium (μ₁ > μ₂) into the lighter medium, the angle of refraction "r" is more than the angle of incidence "i" at the boundary between them. They are related by :
μ₂/μ₁ = Sin i / Sin r = constant
As i increases, r also increases. At a particular angle called the critical angle "i_c", the angle of refraction becomes 90° and grazes the boundary. When the angle of incidence is increased further, the light rays are all totally reflected back into the denser medium. The reflected rays follow the laws of reflection.
Normally, when light rays are incident at a surface, they are partially reflected, scattered and partially refracted. In case of total internal reflection, all the rays are totally reflected. So the images viewed like mirages, or objects like diamonds, prisms, optical fibre shine very brightly.
In an optical fibre the light rays are incident from air into the fibre at one end of it. The light rays get refracted into the fibre at angles such that they fall on the boundary between the core and cladding layers at angles more than critical angles. So they get totally internally reflected throughout the length of the fibre.
In diamonds, the light rays from air get refracted in to diamond at high angles, and they get reflected at multiple edges and totally internally reflected when the angles are more than critical angle for diamond.
In a desert, the ait near the sand is very hot and is lighter. The air at 1 meter height is cooler and so denser. The light rays from a distant tree or building top are incident on the boundary of the these two air layers. They get reflected when the angle of incidence is more than critical angle.