ZTest Always Vs. 2nd camera

I’m talking about getting certain object to always be on top of everything. A modified shader with ZTest Always or a 2nd camera with settings to only render the target object. Anyone know which would be better for performance?

Don’t use a seperate camera and render texture just to do this.

You can either make a shader with the queue after everything else to accomplish this or manually set material.renderQueue.

So if you have a material for something you wish to have draw after everything else. you set material.renderQueue to 4000 or 4001 which is after overlay see here.

Render textures are expensive, more so on mobile devices.

So use ztest always on the shader and set the “Queue” to “Overlay+1”, ZWrite to off, and ZTest to Always

What about a camera with higher depth setting and culling mask set with no render texture would that still be slower?

Yea, I mean its less resource heavy than using a render texture. But it will still have to go through and cull everything out. If you do go that route though, do use layers. It makes a big impact on your project as you’ll then need to have all main cameras cull that layer out, and then the camera which does the second pass cull out everything but that layer.

The best way to do it is how i first mentioned, the only reason i would go to the second render route is if there was a need to. Like if your making a HUD it probably makes sense to use a second camera. In my project i’ve got 2-3 cameras, the first clears and renders skybox scene on its own layer, second only clears depth and renders world, and i use a third only during transitions ( like a looney tunes circle zoom crossfade ). Theres definitely penalties going this way, but if you need to, you need to. Culling overall is pretty fast for me though i don’t have alot of complexion. It gets more expensive though the more you tie into camera things ( and the more you do in those functions ) ie. OnPreCull, OnPostRender, ect. and yea, i do not use render textures. I’ve tried it and the performance wasn’t great along with the memory constraints.

ok Thanks