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?
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.