How to make "Enable GPU Instancing" checkbox appear on the shader?

I have written a very basic shader as follows. What I have to add to enable GPU instancing?

Shader "Unlit/NoteColor"
{
    Properties
    {
        _Color ("Main Color", Color) = (1,1,1,1)
        _MainTex ("Texture", 2D) = "white"
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }

        Pass
        {
            ZWrite Off
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma target 2.0
           
            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;
            fixed4 _Color;
           
            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                return o;
            }
           
            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 col = tex2D(_MainTex, i.uv);
                return col;
            }
            ENDCG
        }
    }
}

For example, this checkbox is available in Mobile/Diffuse.

3292025--254965--Screenshot 2017-11-18 16.05.37.png

1 Like

there is example in docs,

2 Likes

Thanks. I have been there before but how did I miss that…

#pragma multi_compile_instancing

5 Likes

Above link is a bit old I guess. Here are the actual lines of code for people searching this exact topic in 2023

1 Like