Look Through effect without image effect

Hello fellow developers,

We have the following effect in our game (see attached image). When the player is behind a wall it will be highlighted in a solid color. The question is if it’s possible to do that without image effect?
Currently we are writing into the custom stencil buffer and using an image effect to check for occlusion and color it accordingly. But in an effort to eliminate image effects to save performance, we are looking for a way to move this to the shader/material on the player.

I have a unity background and I remember that it was possible to have a shader with different passes. One for the normal material and one for when the depth-test would fail which writes the solid color into it. Is this or something similar possible in UE4?

Greetings,