[Solved] Render order trouble - Opaque vs Transparent

Hello, I’m getting really frustrated and would really appreciate some help.

For stencilling reasons, I need a “hole” to render before the “floor”. Problem is, my floor always renders first.

My floor shader is a surface shader, while my hole shader is not a surface shader. I’ve tried every combination of setting Queue and RenderType Tags on each to Transparent, Opaque, and Transparent-10. I’ve tried every combination of enabling/disabling blending, zwrite, and ztest.

The crazy part is that the frame debugger always shows that it renders my floor first as an opaque object and my hole next as a transparent object. Even when I change the queue/renderType of each shader, this fact is always the same.

How in the hell do I make my hole shader render first??

Ok, I found a workaround. It seems surface shaders don’t care for render queues and will completely ruin the order of rendering.

To get the floor rendering before the holes, I had to give the floor the hole material then set that material back to the floor shader. Likewise, I gave the holes the floor material and switched the shader back to the hole shader.

I’m a bit angry because that change should have done nothing, but it completely changed my render order. Surface shaders seem to do nothing but cause problems in all my Unity shader experience, but I can’t live without them because lighting is a pain. UHHG.

I had the very same problem the other day.
Have a look inside the debug view of your material’s inspector.
If the value of “Custom Render Queue” is not -1, then the value specified in your shader is being overridden.
2618857--183833--CustomRenderQueueDebug.png

1 Like

Perfect, you’re right! I feel much better knowing why this happens now, I wish it wasn’t so well hidden. They should add a note about this in the shader lab documentation where they talk about render queues.

It’s a really annoying issue. At least it’s filed in their issue tracker, so it should get fixed eventually.
[Material] Render Queue value is not updated until shader is changed and reverted

2 Likes

Please vote on that issue so they pay more attention to it. It’s a very frustrating bug for shader dev.

2 Likes