I Use Command Buffer and “DrawRenderer” to add a couple of additional renderers with a custom material to camera render sequence, but it seems that my shader settings for ZTest are ignored. The objects seem to be drawn in the order in which they were added to the command buffer regardless of their depth. I shove the command buffer in “CameraEvent.BeforeImageEffectsOpaque”.
The strange thing is, that if i add the Optimized blur from Unity standard assets to the camera that results in everything getting drawn with proper depth test.
So in general is the injection area wrong, does command buffer simply forgo depth test or is there something I fundamentally don’t get about computer graphics render sequences/tests etc.?
Thank you for your time!
EDIT #1
So I’ve been trying to narrow down what causes the proper depth test in optimized blur. And it seems that simply adding this to the camera that has the command buffer assigned, makes the content of the command buffer adhere to depth:
As to why I cannot say yet. Since my command buffer has around ~4 renderers, and this “OnRenderImage” doesn’t get called more than once per frame, it seems that it simply copies a complete texture into another complete texture. Why this copying forces the command buffer commnads to adhere to depth, I do not know.
In case anyone still comes across this issue, I had the same and in my case it was also a simple mistake that was probably the same as the one in the original post.
When getting the temporary render texture in the command buffer, I mistakenly gave the depth buffer a bit size of 0 instead of 16 or more. It looked something like this:
It was still not worded…
I had checked the depth info in Frame Debugger, it just a pure white picture when executed “commandBuffer.Blit(BuiltinRenderTextureType.CameraTarget, [RT with depth], [material with Z Write on]);” .