I was thinking about this today and whether Cycles may eventually get nested dielectrics at some point in the future.
For those who don’t know, nesting dielectrics would allow you to simulate things like ice cubes in a glass of water, orbeez in a vase etc. In these cases, because you have a transparent/refractive object submerged in a second transparent/refractive medium, the way light refracts depends on whether you are viewing the object above the liquid, or submerged below it.
For example, when you submerge saturated orbeez in water - it looks like they disappear (see video below).
Then it struck me - a solution already exists in Cycles using the light path node. No idea why I hadn’t thought of this before:
Basically - you give your object the shader group shown below. You set the IOR of the bottom glass node to the material you want it to be (e.g. ice in this case). Then you set the IOR of upper glass node to 1 + the difference between the object IOR and the IOR of the medium it is submerged in (in this case I have submerged ice in a cube with an IOR indicative of water - so the difference is -0.024).
Now when you submerge the ice ball, the IOR reacts correctly depending on whether you are viewing the ice above the water, or the ice submerged because the shader group knows whether you are viewing it through a refractive medium or not due to the light path node.
If the object had the same IOR as the medium (like in the case of an Orbee in water), the top glass node would have an IOR of 1 and the object would look like it has disappeared when submerged due to the lack of any discernible difference in IOR between the object and the medium.
This approach does have it’s limitations in as much that it can only handle one level of nesting - but it’s better than nothing I guess.