My shader does not word under iOS

Hello!
Please help me with my problem - shader does not work under OpenGL ES, but work in SM2.0 mode and higher.
It’s combining and mixing several textures with cutouts from mask (e.g stones from grass/sand)
Here it is:

Shader "Custom/Demo" {
    Properties {
        _Grass ("Grass", 2D) = "" {}
                _Dirt ("Dirt", 2D) = "" {}
                _Mask ("Mask", 2D) = "" {}
                _DirtMask ("DirtMask", 2D) = "" {}
                _BumpMap ("Bump", 2D) = "" {}
                _BumpGrass ("BumpGrass", 2D) = "" {}
                _GrassSand ("Grass Sand", 2D) = "" {}
        }
    SubShader {
        Tags { "RenderType"="Opaque" }
        
        CGPROGRAM
        #pragma surface surf Lambert
        #pragma exclude_renderers flash

        sampler2D _Grass;
        sampler2D _Dirt;
        sampler2D _Mask;
        sampler2D _DirtMask;
        sampler2D _BumpMap;
        sampler2D _BumpGrass;
        sampler2D _GrassSand;

        struct Input {
            float2 uv_Grass;
            float2 uv_Dirt;
            float2 uv_Mask;
            float2 uv_DirtMask;
            float2 uv_BumpMap;
            float2 uv_BumpGrass;
            float2 uv_GrassSand;
        };

                float3 blend(float4 texture1, float a1, float4 texture2, float a2)
        {
            float depth = 0.09;
            float ma = max(texture1.a + a1, texture2.a + a2) - depth;
            float b1 = max(texture1.a + a1 - ma, 0);
            float b2 = max(texture2.a + a2 - ma, 0);
            return (texture1.rgb * b1 + texture2.rgb * b2) / (b1 + b2);
        }
        
        void surf (Input IN, inout SurfaceOutput o) {
                
                float4 c1 = tex2D (_Grass, IN.uv_Grass);
            float4 c2 = tex2D (_Dirt, IN.uv_Dirt);
            half4 c3 = tex2D (_Mask, IN.uv_Mask);
            half4 c4 = tex2D (_DirtMask, IN.uv_DirtMask);
            half4 c5 = tex2D (_BumpMap, IN.uv_BumpMap);
            half4 c6 = tex2D (_BumpGrass, IN.uv_BumpGrass);
            float4 c7 = tex2D (_GrassSand, IN.uv_GrassSand);
            
            float H = 0.3 * c4.r + 0.59 * c4.g + 0.11 * c4.b;
            float M = (c3.r + c3.g + c3.b) / 3;
             
            float4 result;
            result = lerp(c1,c7, (1-c3.a)+0.4 );
                
            o.Albedo = blend(result, 1-H, c2, 1-M);
            o.Normal = UnpackNormal(lerp(c5,c6,M));
        }
        ENDCG
    } 
    FallBack "Diffuse"
}

I became happy when it starts working under iOS!
Thx!
:smile:

It might be because it’s a per pixel light shader and you are using vertex lights?

ThankYou!
I’m using forward rendering, no vertex light, but I tried to hide

and it worked!!! But without BumpMapping.
How can I repair it under iOS?

Maybe you should try testing it without using the lerp on your normal. Also be careful of mixing different precisions half and float.

Thank You!
What the difference between half and float?

half is half precision 16 bit and float is 32 bit.

This is a good article Unity - Manual: Optimize shader runtime performance