I'm working on a raymarching shader, which is a canvasitem shader on a full-screen ColorRect - it reads from the SCREENTEXTURE and adds the raymarched objects to that color.
Currently, raymarched objects are always on top of other objects drawn by the engine. I'd like to access the depth buffer in my shader so that I can stop the march when I'm exceeding the depth at that pixel. However, I can't find a way to access the depth buffer in a canvasitem shader in the documentation - there's only SCREENTEXTURE with no depth component.
I've also tried turning it into a spatial shader, but it seems like 2D objects like ColorRects don't do anything with those.
Is there a way to do this?