Search Unity

U5 shader coming out solid black on newer iOS devices (iPad 2 Air / iPhone 6) - Metal / ES3.0 Issue?

Discussion in 'Shaders' started by poolts, Oct 12, 2015.

  1. poolts

    poolts

    Joined:
    Aug 9, 2012
    Posts:
    113
    After upgrading to Unity 5 (latest v5.2.1p3), the mesh the following shader is applied to is coming out solid black on iPhone 6 and iPad 2 Air. It's working correctly on older iOS devices (i.e. iPad 2 / iPhone 4S) and Android devices, just not on newer iOS devices. I'm wondering if ES3.0 or Metal could be causing the problem.

    Error codes are:

    WARNING: Shader Unsupported: 'Standard' - Pass 'FORWARD' has no vertex shader

    WARNING: Shader Unsupported: 'Standard' - Pass 'FORWARD_DELTA' has no vertex shader

    WARNING: Shader Unsupported: 'Standard' - Pass 'SHADOWCASTER' has no vertex shader

    WARNING: Shader Unsupported: 'Standard' - All passes removed


    Which has also been posted about here: http://forum.unity3d.com/threads/unsupported-shader-errors-in-chrome-and-firefox.351915/

    Here's the shader code:

    Code (csharp):
    1. Shader "Custom/UberKitFE_GR" {
    2.     Properties {
    3.         _MainTex ("MainTex", 2D) = "white" {}
    4.         _NumberC ("NumberC", Color) = (0.5,0.5,0.5,1)
    5.         _Number ("Number", 2D) = "white" {}
    6.         _BumpMap ("BumpMap", 2D) = "bump" {}
    7.         _Wrap ("Wrap", 2D) = "gray" {}
    8.         _WrapIntensity ("Wrap Intensity", Range(0, 1)) = 0.5
    9.         _FresnelColor ("Fresnel Color", Color) = (0.5,0.5,0.5,1)
    10.         _FresnelIntensity ("Fresnel Intensity", Range(0, 100)) = 1
    11.         _FresnelExponent ("Fresnel Exponent", Range(0, 3)) = 2.5
    12.         _SpecularIntensity ("Specular Intensity", Range(0, 0.25)) = 0.13
    13.         _Shininess ("Shininess", Range(0, 50)) = 25
    14.         _GlossMap ("Gloss Map", 2D) = "white" {}
    15.         _Diffuse ("Diffuse", 2D) = "white" {}
    16.         _U5tint ("U5 darken", Range(1, 4)) = 3.6
    17.     }
    18.     SubShader {
    19.         Tags {
    20.             "RenderType"="Opaque"
    21.         }
    22.         Pass {
    23.             Name "ForwardBase"
    24.             Tags {
    25.                 "LightMode"="ForwardBase"
    26.             }
    27.        
    28.        
    29.             CGPROGRAM
    30.             #pragma vertex vert
    31.             #pragma fragment frag
    32.             #define UNITY_PASS_FORWARDBASE
    33.             #include "UnityCG.cginc"
    34.             #include "AutoLight.cginc"
    35.             #include "Lighting.cginc"
    36.             #pragma multi_compile_fwdbase_fullshadows
    37.             #pragma exclude_renderers d3d11 xbox360 ps3 flash d3d11_9x
    38.             #pragma target 3.0
    39.             uniform sampler2D _MainTex; uniform fixed4 _MainTex_ST;
    40.             uniform sampler2D _BumpMap; uniform fixed4 _BumpMap_ST;
    41.             uniform sampler2D _Wrap; uniform fixed4 _Wrap_ST;
    42.             uniform fixed _WrapIntensity;
    43.             uniform fixed _FresnelExponent;
    44.             uniform sampler2D _Number; uniform fixed4 _Number_ST;
    45.             uniform fixed4 _NumberC;
    46.             uniform fixed _SpecularIntensity;
    47.             uniform fixed _Shininess;
    48.             uniform fixed _FresnelIntensity;
    49.             uniform sampler2D _GlossMap; uniform fixed4 _GlossMap_ST;
    50.             uniform fixed4 _FresnelColor;
    51.             uniform fixed _U5tint;
    52.             uniform sampler2D _Diffuse; uniform fixed4 _Diffuse_ST;
    53.             struct VertexInput {
    54.                 fixed4 vertex : POSITION;
    55.                 fixed3 normal : NORMAL;
    56.                 fixed4 tangent : TANGENT;
    57.                 fixed2 texcoord0 : TEXCOORD0;
    58.                 fixed2 texcoord1 : TEXCOORD1;
    59.             };
    60.             struct VertexOutput {
    61.                 fixed4 pos : SV_POSITION;
    62.                 fixed2 uv0 : TEXCOORD0;
    63.                 fixed2 uv1 : TEXCOORD1;
    64.                 fixed4 posWorld : TEXCOORD2;
    65.                 fixed3 normalDir : TEXCOORD3;
    66.                 fixed3 tangentDir : TEXCOORD4;
    67.                 fixed3 binormalDir : TEXCOORD5;
    68.                 LIGHTING_COORDS(6,7)
    69.             };
    70.             VertexOutput vert (VertexInput v) {
    71.                 VertexOutput o = (VertexOutput)0;
    72.                 o.uv0 = v.texcoord0;
    73.                 o.uv1 = v.texcoord1;
    74.                 o.normalDir = mul(_Object2World, fixed4(v.normal,0)).xyz;
    75.                 o.tangentDir = normalize( mul( _Object2World, fixed4( v.tangent.xyz, 0.0 ) ).xyz );
    76.                 o.binormalDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
    77.                 o.posWorld = mul(_Object2World, v.vertex);
    78.                 fixed3 lightColor = _LightColor0.rgb;
    79.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    80.                 TRANSFER_VERTEX_TO_FRAGMENT(o)
    81.                 return o;
    82.             }
    83.             fixed4 frag(VertexOutput i) : COLOR {
    84.                 i.normalDir = normalize(i.normalDir);
    85.                 fixed3x3 tangentTransform = fixed3x3( i.tangentDir, i.binormalDir, i.normalDir);
    86. /////// Vectors:
    87.                 fixed3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
    88.                 fixed3 _BumpMap_var = UnpackNormal(tex2D(_BumpMap,TRANSFORM_TEX(i.uv0, _BumpMap)));
    89.                 fixed3 normalLocal = _BumpMap_var.rgb;
    90.                 fixed3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
    91.                 fixed3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
    92.                 fixed3 lightColor = _LightColor0.rgb;
    93.                 fixed3 halfDirection = normalize(viewDirection+lightDirection);
    94. ////// Lighting:
    95.                 fixed attenuation = LIGHT_ATTENUATION(i)*2;
    96. ////// Emissive:
    97.                 fixed4 _GlossMap_var = tex2D(_GlossMap,TRANSFORM_TEX(i.uv0, _GlossMap));
    98.                 fixed3 emissive = ((_FresnelIntensity*(pow(1.0-max(0,dot(normalDirection, viewDirection)),_FresnelExponent)*i.posWorld.g*i.posWorld.g)*_FresnelColor.rgb)+(pow(max(0,dot(normalDirection,halfDirection)),(_Shininess*_GlossMap_var.r))*_SpecularIntensity));
    99.                 fixed2 node_44 = fixed2(0.5*dot(normalDirection,lightDirection)+0.5,0.0);
    100.                 fixed4 _Wrap_var = tex2D(_Wrap,TRANSFORM_TEX(node_44, _Wrap));
    101.                 fixed4 _Number_var = tex2D(_Number,TRANSFORM_TEX(i.uv1, _Number));
    102.                 fixed node_3845 = (1.0 - _Number_var.a);
    103.                 fixed4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
    104.                 fixed3 node_4347 = ((_NumberC.rgb*_Number_var.a)+((node_3845*node_3845)*_MainTex_var.rgb));
    105.                 fixed4 _Diffuse_var = tex2D(_Diffuse,TRANSFORM_TEX(i.uv0, _Diffuse));
    106.                 fixed3 finalColor = emissive + (((((_Wrap_var.rgb*_WrapIntensity)*node_4347)+(UNITY_LIGHTMODEL_AMBIENT.rgb*node_4347))+(node_4347*max(0,dot(lightDirection,normalDirection))))*(_LightColor0.rgb*attenuation)*_Diffuse_var.rgb);
    107.                 fixed3 finalColorU5 = finalColor / _U5tint;
    108.                 return fixed4(finalColorU5,1);
    109.             }
    110.             ENDCG
    111.         }
    112.     }
    113. }
    114.  
     
  2. skok

    skok

    Joined:
    Jul 13, 2015
    Posts:
    6
    We have the same error messages on our project (using Unity 5.2.3f1). The affected phone is the iPhone 5c, model number A1507, which Xcode tells me only supports OpenGL ES2.

    The shaders that are actually not rendering properly on this platform are the standard Mobile/VertexLit shader and one custom surface shader. The bug is that the object just disappears completely, for both shaders. Whether the object disappears seems to depend on camera angle or world position, not certain which.

    In addition to that error, we also have this one:

    I'll be honest, I have NO clue yet on how to solve it.

    The custom shader is simple:
    Code (CSharp):
    1. Shader "SEED/CharacterFlashFx"
    2. {
    3.     Properties
    4.     {
    5.         _MainTex("Base (RGB)", 2D) = "white" { }
    6.         _BlendColor("Blend Color", Color) = (1, 1, 1, 0)
    7.     }
    8.  
    9.     SubShader
    10.     {
    11.         Tags{ "Queue" = "Geometry" }
    12.  
    13.         CGPROGRAM
    14. #pragma surface surf Lambert noforwardadd
    15. #pragma multi_compile __ FLASH_ON
    16.  
    17.         sampler2D _MainTex;
    18.         float4 _BlendColor;
    19.    
    20.         struct Input
    21.         {
    22.             float2 uv_MainTex;
    23.         };
    24.    
    25.         void surf(Input IN, inout SurfaceOutput o)
    26.         {
    27. #if defined (FLASH_ON)
    28.             o.Albedo = lerp(_BlendColor, tex2D(_MainTex, IN.uv_MainTex).rgb, 1.0 - _BlendColor.a);
    29. #else
    30.             o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;
    31. #endif
    32.             o.Alpha = 1.0;
    33.         }
    34.    
    35.         ENDCG
    36.     }
    37.     Fallback "Diffuse"
    38. }
    39.  
     
    Last edited: Dec 14, 2015
  3. skok

    skok

    Joined:
    Jul 13, 2015
    Posts:
    6
    Okay, so after capturing a frame and looking at the actual call that causes the error, I found out that the cause was an object with Unity's Quad mesh and a Mobile/VertexLit shader. After changing this material to use an Unlit shader, the game ran fine. This includes the other shaders in the game, so I guess the GL State was simply invalidated, causing other render passes to act strange. I don't have time to investigate further, unfortunately.

    The warning about the 'Standard' shader still happens for me, but there is nothing wrong on screen. I guess I had a different issue and this won't help you much. My guess is, though, that the warning you see is not actually related to your shader.