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

Introduction to the shader programming language

3.1.3. ShaderLab SubShader

This post is also available in…

The second component of a shader is the SubShader. Each shader is made up of at least one SubShader for the perfect loading of the program. When there is more than one SubShader, Unity will process each of them and take the most suitable according to the hardware characteristics, starting from the first to the last on the list. To understand this, let’s assume that the shader is going to run on hardware that supports metal graph API (iOS). For this, Unity will run the first SubShader that supports metal graphs and run it. When a SubShader is not supported, Unity will try to use the Fallback component that corresponds to a default shader, so the hardware can continue with its task without graphical errors.

Shader “InspectorPath / shaderName”
{
    Properties {} …
    SubShader
    {
        // shader configuration here 
    }
}

If we pay attention to our USB_simple_color shader, the SubShader will appear as follows in its default values: 

Shader “USB / USB_simple_color”
{
    Properties {} …
    SubShader
    {
        Tags { “RenderType” = “Opaque” }
        LOD 100

        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-logo

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.