You need to compare the regular depth pass to the custom depth pass to detect if the object is being covered up by something else or not. If the custom depth value is nearer or equal to the regular depth, then you know it is unobstructed. If the regular depth is nearer than the custom depth, then an object is blocking it and you can mask out the color.