Get Custom Depth Between Two Intersecting Meshes (Post Processing)

Hi All,

I need to do a post processing effect in which I render an outline between objects overlapping relative to the camera view. Please see the image attached below for an example of what I mean…

I have the stroke and masking using custom depth working no problem. I assumed I would be able to use the stencil buffer to detect overlapping parts of the image, however now it appears to me that the stencil buffer is masking a single depth pass, rather than (what I assumed) a depth pass per stencil channel…
Is there really no way to achieve this?! I assumed it was going to be possible and now I’ve progressed quite far with the project @_@

Any thoughts, advice or leads very appreciated.

Cheers, Jimmy

Render figure into custom depth. Use separate mesh with outline material that has depth test disabled. Set opacity to 1 only if pixel depth is greater than custom depth.

Hi Deathrey. I’m sorry but I don’t fully understand, but I do think you’re onto something.

separate mesh with outline material
The outline is achieved via post processing. This is ideal as I want the lines to remain same thickness no matter how close/far. Is this still compatible with your solution? perhaps something using stencils?

@Deathrey so I followed your advice and I think ive done it correctly? However the issue here is now the outline information is opaque. If I can somehow write to an invisible channel so that this outline mesh is then not visible in render, but used for a post process sobel operation, that would be perfect!
however cant find a way to do this…

Actually, come to think about it, even with what I mentioned above this still has a problem… See the original image above how there is a third person with an entire outline? this method will result in a continous blobby outline for everything it intersects @_@