Disco Elysium like depth sorting

Dear developers,

I am currently working on recreating the graphics of Disco Elysium, which, as you may know, is an isometric game that combines a 2D background image with 3D characters walking on a surface. To occlude the characters when they move behind obstacles, the game uses depth sorting and depth maps. I have already rendered both the diffuse and depth passes and imported them as bitmaps. I have positioned them to create a three-dimensional effect from a certain point of view, similar to what was made in “Pillars of Eternity”. What I need is to occlude the top-down character on a pixel-per-pixel basis, depending on the depth map placed on a plane. The camera is orthographic, so there is no perspective. To achieve this effect, I need to calculate the distance between the camera and character, and between the camera and the depth of the plane. Then, I need to somehow compare them to automatically occlude or show the character.

However, as I am new to UE, I am unsure how to implement this sorting. I have searched for solutions on YouTube and in the documentation, but I have not found an explanation for my specific case.

Currently, the level condition is poor. To achieve the desired effect, I have simply placed an instance of the plane and made a copy of the material with an opacity mask. This mask makes the parts of the image with objects “in front of the character” visible while keeping the rest of the background image transparent. However, this method relies on primitive sorting and presents issues when the character walks into areas it should not, which breaks the illusion.

Can you please explain me how can I do this? Are there any approaches on how to make such sorting, and what should I read to succeed? Blueprint and material editor screenshots or code in C++ (if needed) are appreciated.

Hello, have you found a solution ?
At the moment, I’m also working on a game like Disco Elysium. I’ve seen that you can create a Custom Depth with the post-process material: https://medium.com/unreal-engine-material-guides/overlapping-custom-depth-stencils-a084aa763f10

Hello, thank you for your answer. Unfortunately, this does not help me, because I need to use pre-rendered depth mask that will automatically solve depth, and using sprites to move around them can make some lighting problems. Imagine that your character walks with a torch around an obstacle made of sprite, how will the light behave in that case? It will cast a shadow of a plane, and the light won’t look as it should. And yes, this somehow works fine only if I use emissive color, whereas I need to use a normal map.

ZaUm did it different way.