How to make widget visible through the selected objects

Based on the answer of the question below:

I would like to know how to prevent view overlapping for actors with a certain custom depth stencil value. Is there a parameter to change on these actors? Do I need to enable Render CustomDepth Pass and change the CustomDepth Stencil value of these actors? And is there a parameter to change in the material function?

Let’s say I have a basic first person project (I made this project to test purpose) with 2 cubes and a sphere behind each cube. If I apply the Widget3DPassThrough_CustomBase_IgnoreDepth material on the spheres, how to see the first sphere through the first cube, but not on the second?

Now in my VR project, I have to see 3D widget through certain actors or meshes, but not through walls or some other actors.