Hiding objects behind glass specifically seems arbitrary, it should be a special kind of material instead that occludes things behind it that are tagged in some way or another, or some special kind of object on its own, if anything.
It would be a very awesome feature because it opens up so many new possibilities. However, if you think about it, it really doesn’t make sense. The thing about glass is that you can see through the glass as well as what’s on the other side the glass. If you place an an object that has its material set to glass and it hides objects behind it, it would defeat the entire purpose of what glass is. The solution to this would simply what @buildthomas suggested, with this feature existing with an entirely new material.
The proper way of implementing effects like this is by using the stencil buffer and stencil tests. The glass “hides” objects with transparency > 0 behind it because of the drawing order and the way glass is rendered:
All opaque objects are drawn first
A copy of the frame buffer is saved to a texture
Glass objects are drawn, reading from the framebuffer texture in order to apply the distortion. Glass objects write to the depth buffer just like opaque objects.
Since the glass objects wrote to the depth buffer, objects drawn after this point (non opaque stuff) that are behind the glass won’t show up.
This isn’t really flexible enough to make that kind of effect reliably. With stencil support objects can write/increment/decrement values on the stencil buffer and test against the buffer contents before being drawn. So, for example, a portal geometry would write “1” to the stencil buffer while objects you want to be visible only through the portal would have their stencil test set to “equals 1”, causing them to only render on the screen pixels where “1” was written to the stencil buffer.
However, if Roblox already uses the stencil buffer for other things internally, exposing control over it would be complicated.