Custom Depth on a Material

Hey there community,

so here is my question:

Is there a way to use custom depth only for part of a model, i.e. only a specific material used by the model? I want to be able to highlight the head of a model through walls and used the tomlooman tutorial to get most of it done, but as-is, it will always highlight the whole model since I can only activate custom depth for the whole model.

I could probably split the model and then attach the head model to the torso model, but that would make animating the whole thing a mess. Is there a nother clever way to deal with this?

This is exactly what I’ve been thinking about a couple of days ago. I’ve been looking at the rendering code, trying to figure out how difficult it would be to add a Custom Depth output to materials, but I’ve not had enough time to give it a serious try.

There is also the issue with multiple independent outlines or post-processing effects on different objects. Since you’re only seeing a depth buffer, you can’t differentiate between your objects (at least I don’t know how). However, if you could assign constant depths to your different objects in a material, you could easily filter using some thresholds. Unfortunately there would still be issues with overlapping objects/outlines.