This change in direction causes the pencil to appear to be displaced or broken when viewed from the side of the glass. The angle at which the light bends depends on the refractive indices of the two media and the angle at which the light strikes the boundary between them.
The greater the difference in refractive indices, the greater the amount of bending. Since the refractive index of water is higher than that of air, the light waves bend more sharply when entering the water, resulting in a more pronounced displacement or "break" in the appearance of the pencil. This effect is commonly observed when objects are viewed across the boundary between air and water, making them appear distorted or displaced.