How to swap material based on current render pass?

I want to only see the normals of a certan object, and nothing else.
I want to do what was explained here:

instead of custom depth I want it when rendering normals. my material should be translucent/invisible, and when rendering world normal It gets swapped to an opaque material.