What do you mean by optically denser and optically rarer mediums?
Total internal reflection of a ray of light is possible when the (ic = critical angle, i = angle of incidence)