Only render part of custom depth buffer based on overlap

Hi guys!

We’re trying to achieve a kind of radar which only shows certain meshes behind it, like this:

The issue is, the radar’s “red area” is not static but dynamic, wobbling in front of player. So we need to either make the radar only render certain objects in xray vision, or save them to custom depth buffer and create a mask dynamically from the radar’s shape. Either mesh or UMG.

The first picture in this link, the “Filter all except stencil 1” is exactly what we’re after - only show parts of a certain mesh while within a certain area. But there’s no info on how that specific effect is achieved, we checked the source, there’s only non-local xray setup which makes objects visible through any wall, we want them visible only through one single mesh/UMG that player has as part of UI.

Any ideas on what we can do?

Perhaps buying this plugin and examining how it works would help: Outliner in Materials - UE Marketplace

I am not affiliated with the plugin or its author, but I have purchased it and used it before.

Thanks for the suggestion! We can do all that already, but not make the outline appear only when the object is behind one specific mesh, but not others.