“Spend lots of CPU cycles to do occlusion culling and better sorting (to take advantage of Early Z-cull).”
I really really wish the documentation was more in-depth here. I can only assume it’s talking about Early Z-Cull done near the Geometry Stage of the GPU. Or is it talking about hardware queries whereby the CPU does z-culling and skips draw calls? Which is it? Also, is it automatic or do you have to turn it on somehow?
And more importantly, how do you do custom sorting in Unity? Obviously, the goal here is to make objects closest to the camera get rendered first. But I don’t see much detail on how to interact with the Unity API to do this.
In google, yields the result. I’m not being smarmy but I’m saying that google + unity keyword is really actually helpful as opposed to forum search. In this case:
Note: This is the render order done in shader, but you can override per material: Unity - Scripting API: Material.renderQueue and will not necessarily draw one thing in front of the other. It will merely draw things in that order, and the Z buffer still has to do it’s job. However, if you want to draw things at different depths, your shader can handle this, or you can use another pass, or another camera.
In some cases changing the render order, such as with tile deferred hardware, will enable the hardware to make a decision to cull.
Huh. I expected this to have nothing to do with shaders. My bad!
The Material RenderQueue concept makes sense to me. And it looks like the shader tag is only used as a flag for initially building the render queue. But you can write C# scripts that modify the RenderQueue dynamically.
I see the doc page says this:
“Geometry render queue optimizes the drawing order of the objects for best performance. All other render queues sort objects by distance, starting rendering from the furthest ones and ending with the closest ones.”
So this leads to my next question which is “Where is the detail explaining how the Geometry queue determines best arrangement?” So I searched and found this thread:
Unity seems to have a lackadaisical view about appropriate documentation details. They really ought to just turn the thing into a wiki and be done with it. Or at least turn on Comments and run it like php.net’s documentation.
And the ultimate answer to my concerns is in the following thread (although completely void of technical details)