Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | hexaquo |
I’m working on a raymarching shader, which is a canvas_item shader on a full-screen ColorRect - it reads from the SCREEN_TEXTURE 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 canvas_item shader in the documentation - there’s only SCREEN_TEXTURE 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?