Trying to clear the depth buffer

Godot Version 4.2.1

I’m trying to render a 3D overlay on top of the main scene. The issue has come up before and the suggested solution is to use a SubViewport.

However, this has proven to be a pain to work with since I want to support features like drag and drop between the layers. The overlay has many objects and I don’t think hacks like forcing the overlay to the transparent rendering list or disabling depth testing entirely will work well.

So I had another idea: Why not use a screen filling quad with a shader that clears the depth buffer between rendering the main scene and the overlay? It sounds like it should work, but so far I couldn’t get it to and I don’t know what I’m missing.

The screenshot of my setup should show the idea fairly well and I’ve also linked a minimal test project. If things work as desired, the back cube should render in front of the front cube in the area of the quad.

Any help is appreciated.

Minimal test project:

Edit: Changed the topic from Programming to Shaders.