also, btw, you can even see some form of the effect of time distortion by gravity in a prism. this is caused by a form of resistance to the motion of photons. different wavelengths of photons have a different amount of resonance with the transmitting material, and so in proportion with their wavelength, some is bent more at the interfaces of the different materials than others. it's not quite exactly the same as the phenomenon of gravity affecting time but it is almost certainly related - that is, that matter's spins and orbits of the various elements of atoms and energy particles have an interaction with each other that can cause them to mutually accelerate the more they are interacting (gravity higher = time faster).
refraction is caused by the disjoint between the surface interface between two different kinds of matter (or non matter, as the case may be) and the photon retains its direction vector (essentially its electromagnetic pole) so its "arrow" or vector of forward motion is shifted in relation to the plane of the interface, so the light is crab-walking sideways in relation to that interface contact angle, this is why things under water look like they are in a different place to where they would be if there was no water. what happens with a prism is because the two interfaces are not parallel, as the photon exits the other side, it is now crab-walking in a direction based on the relation of the two interfaces and you get the classic newtonian pink floyd shape. and it is somewhat related to reflection, which is where it passes the threshold from transmission to bouncing the particle, which causes a re-orientation of the photon's axis to a 180 flip compared to its incident vector.
these are both almost certainly related to how time changes its flow speed. from the lower density region, to the higher density region, the relative speed of time does not change in the observer's perspective, but if the observer transits into the higher density region, relative to their old position, their time flow has accelerated, but subjectively all of the things happening in the high density region are still at a consistent relation to each other. like playing a 33 record at 45, or vice versa.