Pre-render into depth buffer

Hey, there

I want to draw some meshes (called ‘ghost’) into depth buffer first, and then draw the total scene which should be passed through that depth buffer. ‘Ghost’ will not be rendered in the second pass. That is, ‘ghost’ just has depth but no color. This could achieve the effect that virtual objects are obscured by real objects in augment reality. How can I do?

I ve tried CustomDepth, but it didnot work in opaque material. Any other way?

Thanks for your attention!