Partially hide sprite3d behind transparent 3d mesh

Godot Version

4.2.1

Question

Hello godot folks, I’ve been chewing on this issue for a while now and haven’t found a viable solution so I’m hoping someone here can point me in the right direction.

Situation: I’m making a game in 3D with a 2D pre-rendered background, using sprite3D for the player. I have transparent objects in my scene that should show the background plus other nodes behind it, but not the player sprite3D. Here are two example images to show what I mean; in one of them, the player sprite (pink square) is in front of the transparent object so should be shown, in the other the player sprite is partially behind the object and so should only be shown partially.


(Excuse the background, I haven’t made assets yet lol)

I had several ideas for how I might do this but none of them really panned out:
-I can use an area3d to see if the player is behind the object… but then how do I hide only the part of the sprite that’s behind the object, not the entire sprite?
-Shaders can hide parts of a sprite… but how do I tell the shader which part?
-This previous thread on here, but I couldn’t get it to work on sprite3D.

Does anyone have any ideas how to do this? Much obliged.