Is it due to fact that light slows down in higher refractive index region. So the material force the light within itself.
Same like a water is flowing in pipe , it flows smoothly but in the case of oil flowing in pipe, it flows slowly.... But in this case instead of refractive index, we have viscosity....
Could you please confirm this please