Imagine that a wave passes from a deeper zone to another shallow zone, or vice versa. There will be refraction. If you want to know what laws govern refraction click here.