Get an 20% OFF using the RELEASE code on your book purchase. For a limited time.

Introduction to the shader programming language

3.1.5. Queue Tags

This post is also available in…

By default, this Tag does not appear graphically as a line of code. This is because it is compiled by default in the GPU as it is directly related to the object processing order for each material.

Tags { “Queue” = ”Geometry” }

This Tag has a close relationship between the camera and the GPU. 

Every time we position an object in our scene, we pass its information to the GPU (e.g. position of vertices, normals, color, etc.). In the Game View case, it is the same with the difference that the information that we send to the GPU corresponds to the object that is inside the frustum of the camera. Once the information is inside the GPU, we send this data to the VRAM and we ask it to draw the object on our screen. 

The process of drawing an object is called a “draw call”. The more passes a shader has, the more draw calls there will be in the rendering. A pass is equivalent to a draw call, therefore, if we have a shader with two passes inside it, then that material will only generate two draw calls on the GPU. 

Now, how does the GPU draw these elements on the screen? In short, the GPU will first draw the objects found farthest from the camera and the elements closest to it will be drawn at the end. This calculation will be made concerning the distance between the object and the camera, following its “Z” axis.

Screen render (1 draw call)
Screen render (2 draw call)

(Fig. 023. As we can see from the picture, the triangle is drawn on the screen first due to it being farthest from the camera. In the end, the square is drawn, and together generate 2 draw calls)

Unity has a processing queue called “Render Queue” which allows us to modify the processing order of objects on the GPU. There are two ways to modify the Render Queue:

  1. Through the properties of the material in the inspector.
  2. Or using the TagQueue“.

If we modify the Queue value in the shader, the default value of the Render Queue in the material will also be modified. 

This property has order values ​​ranging from 0 to 5000, where “0” corresponds to the farthest element and “5000” to the element closest to the camera. These order values ​​have predefined groups, which are:

  • Background.
  • Geometry.
  • AlphaTest.
  • Transparent.
  • Overlay.
//Goes from 0 to 1499, default value 1000. 
Tags {"Queue" = "Background"}
//Goes from 1500 to 2399, default value 2000.
Tags {"Queue" = "Geometry"}
//Goes from 2400 to 2699, default value 2450.
Tags {"Queue" = "AlphaTest"}
//Goes from 2700 to 3599, default value 3000.
Tags {"Queue" = "Transparent"}
//Goes from 3600 to 5000, default value 4000.
Tags {"Queue" = "Overlay"}

Background is used mainly for elements that are very far from the camera (e.g. skybox).

Geometry is the default value in the Queue and is used for opaque objects in the scene (e.g. primitives and objects in general). 

AlphaTest is used on semi-transparent objects that must be in front of an opaque object, but behind a transparent object (e.g. glass, grass or vegetation). 

Transparent is used for transparent elements that must be in front of the other elements. 
Finally, Overlay corresponds to those elements that are foremost in the scene (e.g. UI images).

   Shader “InspectorPath / shaderName”
    Properties {} …
        Tags { "Queue" = "Geometry" } 

High Definition RP uses the Render Queue in a different way than Built-in RP since the materials do not directly show this property in the Inspector, this instead introduces two control methods which are:

  1. Material order.
  2. And render order.

Together, HDRP uses these two order methods for the control of object processing.

Follow us to stay informed about all the latest news, updates, and more.

Join the group to share your experiences with other developers.

Subscribe to our channel and keep learning game dev!


Jettelly Team

We are a team of indie developers with more than 9 years of experience in video games. As an independent studio, we have developed Nom Noms in which we published with Hyperbeard in 2019. We are currently developing The Unity Shader Bible.

Follow us on our social networks.