Depth Buffer in material shader


I try to access the depth buffer in a shader, but sadly since the change to the layer system it is not possible to use ‘;’ to autogenerate the depth texture (as in this example).

There is also a thread discussing post processing effects using depth, sadly without a good solution.

Is there any documentation / example showing how to generate and access the depth texture(for the world layer or any other)?