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

Introduction to the shader programming language

3.2.5. ShaderLab Pass

This post is also available in…

The third component in our shader corresponds to the passes (Pass).

There can be multiple passes within a shader, however, by default Unity adds only one inside the SubShader field.

If we look at our USB_simple_color shader, we will find the following pass included.

    #pragma vertex vert
    #pragma fragment frag
    // make fog work
    #pragma multi_compile_fog

    #include “UnityCG.cginc”

    struct appdata {}; ...

    struct v2f {}; ...

    sampler 2D _MainTex;
    float4 _MainTex;

    v2f vert (appdata v) {} ...

    fixed4 frag (v2f i) : SV_Target {} ...

A Pass refers to a Render Pass. For those who have worked with rendering in 3D software (e.g. Maya or Blender) this concept will be easier for you to understand since when an image is being processed, it can generate different layers or passes separately (e.g. color pass, light pass, occlusion pass, etc) and obtain a separate composition in different layers. 

Each Pass renders one object at a time, that is, if we have two passes in our shader, the object will be rendered twice on the GPU and the equivalent of that would be two draw calls. 

A Pass is equal to a draw call which is why we must use the least amount of passes possible, otherwise, we could generate a significant graphic load.

Shader “InspectorPath / shaderName”
    Properties {} ...
        Tags { “RenderType”=”Opaque”} 
            // first default pass

            // second additional pass

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.