The refraction of starlight by the atmosphere is what causes the twinkling of the stars. Due to the several layers that make up the atmosphere and the constantly changing paths that light rays from the star take, refractive indices are always changing. As a result, the amount of rays entering, the eye’s pupil, and the appearance of the stars flashing change over time.