Refraction is the bending of light when it passes from one medium to another of a different optical density, such as air to water. This bending causes light to change direction as it travels through the new medium. Refraction is responsible for phenomena such as the bending of a pencil in a glass of water and the formation of rainbows.