Currently, Medium2D requires a homogeneous medium as a substrate / superstrate. It would be good to allow inhomogeneous media.
One possibility is to use CustomMedium for the volumetric equivalent of the Medium2D in this scenario. This would take some more effort because we'd have to use the detailed geometric information of the neighboring media.