Why does subtracting SceneDepth from CustomDepth produce an object mask?

I’m following this tutorial to create object masks in post process material by subtracting SceneDepth from CustomDepth. I am confused about why this method gives a perfectly black and white mask.

From my understanding:

  • If a pixel is not written to CustomDepth, its value defaults to 1.

  • The same pixel in SceneDepth should usually be somewhere between 0 and 1 (for example, 0.6).

  • Subtracting the two should give 0.4, which I’d expect to show up as some shade of gray.

But in practice, the result is just black for the CustomDepth objects and white everywhere else.

Could someone explain why this happens? Any clarification would be much appreciated. Thanks!

Here’s the method in the tutorial and the result at a certain frame:

And here is the approach that makes more sense to me, but the result I’m seeing doesn’t look any different: