I admit, I don't really understand depth mapping so if there is anything I should know, tell me.

A Spatial shader can use uniform hint_depth_texture but not a CanvasItem, I'm guessing this is because that Spatial shaders operate in 3D and CanvasItem shaders operate in 2D. Is there any alternative method I can use to access the depth texture in a CanvasItem shader?

  • xyz replied to this.
    6 days later

    xyz Really, I don't know. There's a lot of post processing shaders that can get the depth map (such as a custom HDRP post proc shader in Unity), so I'd guess I want to access it for the same purpose.

    For the CanvasItem, I'd guess I'd have it in there just so I don't have to spend any extra polygons. Unless if that somehow bogs down performance.

    • xyz replied to this.

      altevc Rendering a 2D rect or a 3D sprite in front of the camera will spend the same amount of polygons.

      CanvasItems can't read the depth buffer. If you absolutely need it, you can use a screen aligned quad with a shader that renders the depth texture onto a special subviewport, then grab the subviewport's texture for use in your CanvasItem shaders... But if you're doing all that for the sake of post processing then why not just do the post-processing with the screen aligned quad in the first place?