Mario's shader in Super Mario Galaxy

In Super Mario Galaxy, when Mario walks behind the landscape elements, the parts of his body that are hidden show as a darkened silhouette. However, when Mario walks behind a creature, there is no darkened silhouette, it completely covers him. How did they manage to do that, and is Unity capable of something similar? Is it even a shader trick at all, or are they using multiple cameras somehow to achieve this?

I’ve seen many shader examples of making an object a solid color when hiding behind something else, but nothing as complex as what Mario is capable of.

It sounds like they are using a raycast from the camera to mario to determine if he’s behind terrain or an enemy. I think you can change the z buffer in a shader to keep it from occluding Mario when he goes behind the terrain.