In Diablo and similar games, when the player is behind an object from the point of view of the camera, the object will (partially) become transparent or disappears.
For example, in the picture below (image screenshot at 2:52 in this video), there are several wood beams on top right:
But when the player moves behind them, they disappeared.
How can I achieve a similar effect?
I could split every object into sub-objects. Then cast rays to find intersections, and tune down the opacity of the intersected sub-object to achieve this effect. But this would require a tremendous amount of work for the gazillion objects in the game, is there some more advanced technique?
(question edited according to comments)