Shader that hides/cuts objects between the player and the camera

Godot Version

4.2.1

Question

Hello everyone. I went on a bit of a search to find a good way to hide things between the camera and the player. Most solutions suggest using a raycast to hide whole objects. I wonder if there is a way to do a similar effect to say Baldursgate 3, where only sections get cut out in order to allow seeing the player. Image for reference:

image