An invisible wall

Hello,
I’d like to create an invisible wall capable of preventing the player from seeing an object through it. For example, I’d like to prevent the player from seeing the rest of the level through the window, so I’d like to put an invisible wall capable of preventing the player from seeing the rest of the level, and allowing him to look through the window as if there were nothing there.
I’ve made a sketch that explains it if need be.
Any ideas?

Could probably do this using custom depth passes and a post process material.

Epic has an intro video to the concept on youtube:

In theory, you could do do two custom passes and use the pass with invisible walls to mask the one with hidden items. Might be expensive rendering three times though.