Turns out Unity has changed how global textures are handled with the new version. Please refer to this answer I've got from the Unity staff.
In the end I found a much simpler solution than writing my own rendering feature.
I found out that the camera depth texture is available in the OnRenderObject
call. So I'm just fetching it there and doing my logic etc. in Update
.
Just make sure to add a null check before you start rendering.
Previously in 2021 and prior I also had to wait 1 frame until the depth texture was generated but this was still possible using only the Update
loop.