Shader error on iOS

Hi,
I’m trying to build an AR application for both android and iOS, everything is working fine on both except on iOS I have a shader which is not rendering at all.
Here is the error on the console when the application tries to load the shader on iOS:

The shader was made using Amplify Shader Editor but not by me, I only have access to the shader code:

Shader "Custom/Milk"
{
    Properties
    {
        _BaseColor("BaseColor", Color) = (0,0,0,0)
        _Smoothness("Smoothness", Float) = 0
        _Mask("Mask", Range( 0 , 1)) = 0
        _TimeScale_Text1("TimeScale_Text1", Float) = 0.2
        _TimeScale_Text2("TimeScale_Text2", Float) = 0.1
        _Displacement("Displacement", Float) = 0
        _Tessellation("Tessellation", Float) = 5
        _Cutoff( "Mask Clip Value", Float ) = 0.5
        _MaskTexture("MaskTexture", 2D) = "white" {}
        [HideInInspector] _texcoord( "", 2D ) = "white" {}
        [HideInInspector] __dirty( "", Int ) = 1
    }

    SubShader
    {
        Tags{ "RenderType" = "TransparentCutout"  "Queue" = "Geometry+0" "IgnoreProjector" = "True" }
        Cull Off
        Blend SrcAlpha OneMinusSrcAlpha
       
        CGPROGRAM
        #include "UnityShaderVariables.cginc"
        #include "Tessellation.cginc"
        #pragma target 4.6
        #pragma surface surf Standard keepalpha addshadow fullforwardshadows vertex:vertexDataFunc tessellate:tessFunction
        struct Input
        {
            float2 uv_texcoord;
        };

        uniform sampler2D _MaskTexture;
        uniform float _TimeScale_Text2;
        uniform float _TimeScale_Text1;
        uniform float _Displacement;
        uniform float4 _BaseColor;
        uniform float _Smoothness;
        uniform float _Mask;
        uniform float _Tessellation;
        uniform float _Cutoff = 0.5;

        float4 tessFunction( appdata_full v0, appdata_full v1, appdata_full v2 )
        {
            float4 temp_cast_0 = (_Tessellation).xxxx;
            return temp_cast_0;
        }

        void vertexDataFunc( inout appdata_full v )
        {
            float mulTime102 = _Time.y * _TimeScale_Text2;
            float2 appendResult103 = (float2(0.0 , mulTime102));
            float2 uv_TexCoord104 = v.texcoord.xy * float2( 1,0.09 ) + appendResult103;
            float mulTime99 = _Time.y * _TimeScale_Text1;
            float2 appendResult98 = (float2(0.0 , mulTime99));
            float2 uv_TexCoord92 = v.texcoord.xy * float2( 1,0.1 ) + appendResult98;
            float temp_output_116_0 = ( saturate( ( tex2Dlod( _MaskTexture, float4( uv_TexCoord104, 0, 0.0) ).r + tex2Dlod( _MaskTexture, float4( uv_TexCoord92, 0, 0.0) ).r ) ) * ( 1.0 - v.texcoord.xy.y ) );
            float3 ase_vertexNormal = v.normal.xyz;
            v.vertex.xyz += ( temp_output_116_0 * _Displacement * ase_vertexNormal );
        }

        void surf( Input i , inout SurfaceOutputStandard o )
        {
            o.Albedo = _BaseColor.rgb;
            o.Smoothness = _Smoothness;
            o.Alpha = 1;
            float mulTime102 = _Time.y * _TimeScale_Text2;
            float2 appendResult103 = (float2(0.0 , mulTime102));
            float2 uv_TexCoord104 = i.uv_texcoord * float2( 1,0.09 ) + appendResult103;
            float mulTime99 = _Time.y * _TimeScale_Text1;
            float2 appendResult98 = (float2(0.0 , mulTime99));
            float2 uv_TexCoord92 = i.uv_texcoord * float2( 1,0.1 ) + appendResult98;
            float temp_output_116_0 = ( saturate( ( tex2D( _MaskTexture, uv_TexCoord104 ).r + tex2D( _MaskTexture, uv_TexCoord92 ).r ) ) * ( 1.0 - i.uv_texcoord.y ) );
            clip( ( ( 1.0 - temp_output_116_0 ) + _Mask ) - _Cutoff );
        }

        ENDCG
    }
    Fallback "Diffuse"
    CustomEditor "ASEMaterialInspector"
}

I think I kinda understand what the error is saying but I don’t have the competence to find what to change in the code.
Is there something obvious I’m missing? This runs without issues on android devices, and the shader renders in play mode in the editor, both on Windows and Mac.

Any help is very much appreciated, thanks!

iOS devices don’t support tessellation the same way most platforms do. So Unity has to translate tessellation shaders, which have been written for use with desktop and console platforms, into the form needed for iOS’s Metal graphics API.

The short version is you may need to report this to Unity to get it fixed. Use the in-editor Report Issue dialog with an example project.
The longer version is you should try reporting the issue to Amplify themselves and see if they have a solution, but they may just direct you to Unity too.
Worse case is you may need to remove tessellation.

1 Like

Thank you very much, I’ll try both ways.