Add ability to hide objects behind glass, like the current transparency bug

As a ROBLOX developer, it is often extremely hard / nearly impossible to create portals / other worldly effects for levels.

If the ability to hide objects behind glass, similar to the current part transparency bug was implemented, we could create things like this:

(Hats off to @Ravenshield for this awesome use of the bug)

If the ability to do this were added, we could create worlds that are highly complex and out of this dimension.

22 Likes

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.

16 Likes

I imagine render masks or something similar. It has to be reliable enough to give the developer control over it and still not accidentally forcing the feature on developers who don’t want to use it.

8 Likes

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.

5 Likes

Yeah, that would be better.

Noneoftheless, a feature like this would be great to have.

3 Likes

:sunglasses:

3 Likes

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:

  1. All opaque objects are drawn first
  2. A copy of the frame buffer is saved to a texture
  3. 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.
  4. 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.

5 Likes

Just thought I would add another neat use case, by @DataBrain :

3 Likes