Custom Depth Value Outputs?

Just had the same issue, thought I’d share my findings.
After some trying it seems that the Custom Depth values are distances from the camera to the objects in world coordinates.
The value “defaults” to some very large number (roughly 100000000, I wonder why) wherever you have no objects with Render CustomDepth Pass enabled.

To visualise the world distance, I dismiss any values above 500:

And get this (only the black pieces have Custom Depth enabled, and so become white when close enough):

In the end, I just set the the constant in the Subtract node to 100000000 to get the effect I wanted - only objects with Render CustomDepth Pass enabled change the pixels. You can also remove the last Min node to retain world distances.

3 Likes