Masking Geometry

I’m trying to find a rendering technique that will allow me to mask geometry using other objects in my level. Here are some examples of the effect I’m trying to reproduce:

Stencil buffer render test (Unreal)

Antichamber - Museum Room (Unreal)

Portal Room Cubes via Stencil buffer (Unity)

Those first two examples were built in Unreal, so at least now I know it’s possible. I just haven’t found any examples or posts that explicitly breakdown how this technique is implemented.

Are you guys mad at me?

Hey myfavoriteduck. Did you ever find a solution to this?