Version: 2022.3
Language : English
ShaderLab: defining material properties
ShaderLab: assigning a custom editor

ShaderLab: assigning a fallback

This page contains information on using a Fallback block in your ShaderLabUnity’s language for defining the structure of Shader objects. More info
See in Glossary
code to assign a fallback ShaderA program that runs on the GPU. More info
See in Glossary
object. For information on how a Shader objectAn instance of the Shader class, a Shader object is container for shader programs and GPU instructions, and information that tells Unity how to use them. Use them with materials to determine the appearance of your scene. More info
See in Glossary
works, and how Unity chooses when to use a fallback, see Shader objects introduction.

Render pipeline compatibility

Feature name Built-in Render PipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. More info
See in Glossary
Universal Render Pipeline (URP) High Definition Render Pipeline (HDRP) Custom SRP
ShaderLab: Fallback block Yes Yes Yes Yes

Using the Fallback block

To assign a fallback, you place a Fallback block inside a Shader block.

Signature Function
Fallback "<name>" If no compatible SubShaders are found, use the named Shader object.
Fallback Off Do not use a fallback Shader object in place of this one. If no compatible SubShaders are found, display the error shader.

Fallback code examples

This example code demonstrates the syntax for creating a Shader object that has a named fallback.

Shader "Examples/ExampleFallback"
{
    SubShader
    {
        // Code that defines the SubShader goes here.

        Pass
        {                
              // Code that defines the Pass goes here.
        }
    }

    Fallback "ExampleOtherShader"
}
ShaderLab: defining material properties
ShaderLab: assigning a custom editor