Rendering Order Revisited

I know that there are plenty of questions out there related to rendering order:

and more closely related to my issue

However, I’m either misunderstanding this whole concept, or I’m doing something wrong, because I just can’t get it to work at all.

What I want to do is: make sure that a certain object / material / shader is rendered on top of everything else in the scene. That is to say: set the shader to a queue sometime after all the other geometry is rendered, clear the depth buffer, and then render the object so that it appears ‘written over’ the rest of the scene. That way, no matter what other objects get between it and the camera it will always be drawn on top.

I know that this can be done with multiple cameras, but we run into the same problems as the last example above: trying to manage a whole bunch of cameras, framerates dropping, etc. From other folks’ statements (e.g. the top example above that talks about drawing a gizmo that is inside a mesh object) it sounds like what I’m trying to do should be possible, but I’ve tried changing the shader tags, the renderQueue of the material, and everything else I can think of, and nothing seems to have an effect on the depth buffer.

Does the queue actually do what I’m trying to do here, or if not is there another way to do it at any level (shader, object, camera) without resorting to one camera for each object?

Even if use set the render queue, it will still do depth testing, and therefore not draw your object if something is closer to the camera. To achieve what you want, I believe you can disable zbuffer testing by setting

[ZTest Always][1]

as well as a sufficiently high renderqueue in your shader.

Of course, this will only work if your mesh is simple enough to not have any overdraw artifacts.

Another (untested) approach would be to do a two pass render, where the first pass has

ZTest Always 
ZWrite On
ColorMask 0

The second pass has

ZTest LEqual
ZWrite On

and renders the object normally

The effect of the first pass would be to “clear” the zbuffer where you want your object to be drawn and the second pass to actually draw the object