Just watch, and change the "change" variable to change how much slower/faster light travels through the material on the lower half of the screen. The speed is (1/change)x the speed light travels through the upper material; i.e. if change is 2, then light travels 2x slower in the other material, and if change is 0.25, then light travels 4x faster in the other material.
An attempt at simulating wave refraction. Not totally sure this even is how it works though, but at least it looks pretty realistic to me xD