PostProcess silhouette clipping through objects

This set up made the clipping dissapear:


But now the hair isn’t working as it should:

I want it to be like this:


I get the silhouette effect when I plug the saturate node into the lerp alpha, instead of the multiply, but I need something to compare the SceneDepth with the CustomDepth so it won’t render through objects.