Imagine a spoon placed in half a glass of water. The spoon appears to bend at the air-water boundary. This is because the light rays reaching your eyes from under the water change direction when they pass into the air. This phenomenon is known as refraction. There are several factors that determine at what angle a light ray will bend when passing from one medium into another.
Angle of Incidence
If a light ray crosses over from one medium to another -- from air to glass for instance -- perpendicular to the surface between the media, it does not change direction, it passes right through. If, however, it hits the surface at an angle to the perpendicular, it changes direction as it moves into the second medium. The angle the light ray makes with the perpendicular in the first medium is called the angle of incidence. The angle the light ray makes with the perpendicular in the second medium is called the angle of refraction. The relationship between the angle of incidence (i) and angle of refraction (r) is given by Snell's law: sin(r)/ sin(i) = ni/nr, where ni is the refractive index of the first medium and nr is the refractive index of the second medium. For a fixed pair of media, ni/nr is fixed. So it is clear that when the angle of incidence i changes, the angle of refraction r changes as well.
From Snell's law, you can see that the angle of refraction depends on the ratio ni/nr of the refractive indices of the two media. If nr is greater than ni -- for instance when light passes from air (ni = 1.0) to glass (ni = 1.5) -- then the angle of refraction is smaller than the angle of incidence, i.e., the light ray bends toward the perpendicular to the surface between the two media as it crosses into the second medium. If nr is smaller than ni, the light ray entering another medium bends away from the perpendicular to the surface between the two media .
Wavelength of Light
The angle of refraction also depends on the wavelength of light. Visible light of different colors have different wavelengths and slightly different indices of refraction. The difference is so small that you don't see it when white light passes through a flat plate of glass for instance. But when white light passes through a prism and is refracted twice at the two surfaces, each color bends at a different angle and you can clearly see the separate colors.
In some special cases, the index of refraction in a medium can depend on the direction in which light passes through the medium. Certain mineral crystals have two distinct indices of refraction along two directions and are known as birefringent materials. For example, tourmaline is a crystal with two refractive indices: 1.669 and 1.638. For these materials, the angle of refraction depends on the orientation of the boundary between the media with the special axes of the crystal.