Basic Question: Render Queue and ZWrite

I explain this with an example:
I have Cube A at “RenderQueue” = “Transparent+100” and “Z Write On” with alpha blending
and Cube B at “RenderQueue” = “Transparent” and further from the camera than A.

The display will be like:
Cube B will be “clipped” by Cube A, while I think the Cube B shall be rendered first and then “alpha blended” by Cube A.
I tried to set the blending of the shader of cube A to “Zero One” and clearly saw Cube B is clipped by Cube A, which is transparent like a mask.

So Z Write and Z Test will “bypass” the render queue or something? Can anyone explain this to help me on better understanding of the rendering order?

There is an annoying bug in Unity that affects the RenderQueue tag:
[Material] Render Queue value is not updated until shader is changed and reverted

Basically, if you change the RenderQueue value in a shader, it won’t have any effect until you do some material trickery to workaround this bug.

I could imagine your issue is related to that, or at least give it a try. I stumbled across various really odd mask/clip/order issues caused by this bug.

To test if it’s related to this bug, switch the Inspector to Debug Mode. Then select your “Cube A” and “Cube B” materials and set their “Render Queue Order” property to -1. This will make sure it uses the RenderQueue from the shader, rather than the cached value in the material.

Here is a related post that shows how to workaround the issue:

1 Like

OH MY GOD…
Yes, that what happened. Thanks a lot, I would start to question my whole understanding of queue order :slight_smile: if I didn’t see your reply.

1 Like