- Home /
Should I concern myself with Render Queue since it's often made public in the inspector?
When I download shaders en scripts from the assets store I noticed that they contained quite often Public Render Queue's with a default value of 3000. I know that Render Queue's are telling Unity what to render first, so should I concern myself with that or in some situations? Why is the default value a lot of times 3000?
Answer by Bunny83 · Jul 07, 2019 at 08:34 PM
Well, the render queue is actually an integer which specifies the order in which the different materials are rendered. However there are well defined ranges which have a distinct meaning. Have a look at this page where the different render queue "groups" / ranges are explained:
Background = 1000
Geometry = 2000
AlphaTest = 2450
Transparent = 3000
Overlay = 4000
The important thing is the number 2500. All queues from 0 - 2500 are considered opaque. Everything above 2501+ is considered transparent. This has a major impact on how they are rendered.
Opaque geometry (everything with a renderqueue up to 2500) is rendered Front to Back. Transparent geometry is rendered Back to Front. Note that this only depends on the render queue, not on what the shader actually does. Transparent geometry has to be rendered back to front to get proper blending (See Painter's algorithm).
The reason why opaque geometriy is sorted the other way round is to avoid overdraw. Your GPU has a certain fillrate. If you draw opaque objects which are close to the camera first they will, thanks to the depth buffer, prevent any drawing in those screen areas where there might be more objects further away.
Note that Unity sorts the objects just on the pivot / origin positions fro mthe camera and not on a per triangle basis. Keep in mind that shaders like Transparancy cutout shaders are not actual transparent shaders. Since they do not need to perform any kind of blending they are actually rendered with the opaque objects. The fragment shader just either renders an opaque fragment or non at all (because it discards the fragment). That's why cutout shaders are way better for performance.
Thank you for ur good explanation! So if I put a background(skybox) image in my scene is it the shader that contains the render queue order or is it the distance to the camera that will deter$$anonymous$$e the render order? Do u also know why Overlay is rendered lastly, shouldn't you make it render first with a depth buffer(if u have a HP bar then that area will never contain any opaque geometry?). @Bunny83 (I maybe have posted 2 same comments but I can see only one)
Your answer
Follow this Question
Related Questions
How do i change the Alphasorting Center to the Pivot in Meshrenderers? 0 Answers
What is the best way to render groups of flat planes using a shader 1 Answer
Extend screen space reflections in hdrp 0 Answers
How to change Render mode in URP at runtime? 1 Answer
Always render object behind everything (not multiple cameras) 1 Answer