I'm trying to create a see-through effect in 3D to display the player and their surroundings behind big obstacles like walls and such.
So far I've setup multiple Viewports rendering 3 different layers on top of each other:
- Background: whatever isn't between the camera and the player.
- Mask: the spatial objects containing the shapes that will mask the foregroung.
- Foreground: obstacles between the camera and the player with an alpha mask applied.
It was extremely difficult to set this up, in contrast to another method using the Stencil Buffer, unfortunately not supported currently in Godot 3.2, but it works.
However, I just realized that I get no shadows from the obstacle itself when the mask is applied, since I use different layers for the background and the foreground objects.
My question is: Is there a way to do it currently in Godot 3.2? If not, will the use of Stencil Buffer solve it in Godot 4.0?
Update: I was able to get the shadows properly, nothing fancy, I just applied the mask properly over the foreground instead of redrawing the masked background. But now, the problem still remains as I'm not able to sort the rendering order of the obstacles when one of them is getting the mask applied to, and is behind another without the mask applied, like the image below: