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

Introduction to the shader programming language

3.3.4 ShaderLab Fallback

This post is also available in…

As mentioned above, this property allows us to assign a shader type object to the object in case our SubShader generates an error or is not compatible with the target hardware. 

Its syntax is as follows:

Fallback "shaderPath"

Shader Path” corresponds to the name and path of the shader that we want to use in case the SubShader fails.

The fallback can also be undeclared, leaving the space blank or using “Fallback Off”, all the same, it is recommended to use a path and names of shaders that have been included in Unity such as “Mobile/Diffuse”. This way we can be sure that our shader will keep compiling in case of failures.

Shader “InspectorPath / shaderName”
{
    Properties {} ...
    SubShader {} ...

    Fallback “Mobile / Unlit”
}

In the previous example, the Fallback will return an “Unlit” type shader belonging to the category “Mobile” in case the SubShader generates an error. 

If we are developing a multiplatform game, it is advisable to declare a specific path for the Fallback, this way we can ensure that our program works on most devices.

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.