I ran into the same problem. I had to create a custom shader to extract the depth. Since I wanted more than 8 bits of depth information, I had to convert the depth into 3 8-bit fields that could go in the RGB components of the image.
In Panda3D Python:
# Set up Shader
dcam = loader.loadShader('Dcam.sha')
# render everything through this camera and shader
self.terrain.getRoot().setShader(dcam)
The shader inputs and outputs also need to be set up (i.e. vtx_position, mat_modelproj, etc. See the examples in the Panda3D documentation.
In Dcam.sha:
//Cg
void vshader(float4 vtx_position : POSITION,
uniform float4x4 mat_modelproj,
out float4 l_position : POSITION,
out float4 l_pos : TEXCOORD0)
{
float4 position = vtx_position;
l_pos = mul(mat_modelproj, position);
l_position = l_pos;
}
void fshader(in float4 l_pos : TEXCOORD0,
out float4 o_color : COLOR)
{
float z = (l_pos.z / l_pos.w) * 0.5 + 0.5;
float zres = 16777216.0 * z;
float v0 = round(zres / 65536.0);
zres = zres - 65536.0 * v0;
float v1 = round(zres / 256.0);
zres = zres - 256.0 * v1;
float v2 = round(zres);
o_color = float4(v0, v1, v2, 1);
}