Author Topic: Android ATOM Device - Unlit/Transparent Colored (SoftClip) Error  (Read 4581 times)

sonicviz

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 58
    • View Profile
Hi,
Got a problem hope someone can solve.
I have an app on Android that works fine on ARM devices.

I can get it to run on an ATOM device - a new ASUS Memo Pad ME176 (ATOM are not officially supported by Unity) by copying the apk but it doesn't run 100%, has some UI issues.
I'm getting some UI bits not showing, and from the logcat (see below) it looks like the problem is the NGUI unlit Transparent Colored shader.
ATOM does some emulation apparently that does not happen under ARM.

According to Unity docs on Player Settings/Android:
Graphics Level    Select either ES 1.1 (‘fixed function’) or ES 2.0 (‘shader based’) Open GL level. When using the AVD (emulator) only ES 1.x is supported.

The app is still using NGUI 2.7 (because it also uses NDATA and they have stopped updating *grrrr angry*) but I've checked the shaders in NGUI 3.6.* and they look the same so I'd probably be getting the same error on latest NGUI anyway.

Any clues / suggestions as to fixing this?

ty!

Crash 1
08-20 12:37:03.998: E/Unity(12066): -------- Unlit/Transparent Colored (SoftClip)
08-20 12:37:03.998: E/Unity(12066): 
08-20 12:37:03.998: E/Unity(12066): (Filename:  Line: 141)
08-20 12:37:03.998: E/Unity(12066): -------- failed compiling vertex program:
08-20 12:37:03.998: E/Unity(12066): 
08-20 12:37:03.998: E/Unity(12066): (Filename:  Line: 142)
08-20 12:37:03.998: D/Unity(12066): #version 300 es
08-20 12:37:03.998: D/Unity(12066): #define gl_Vertex _glesVertex
08-20 12:37:03.998: D/Unity(12066): in vec4 _glesVertex;
08-20 12:37:03.998: D/Unity(12066): #define gl_Color _glesColor
08-20 12:37:03.998: D/Unity(12066): in vec4 _glesColor;
08-20 12:37:03.998: D/Unity(12066): #define gl_MultiTexCoord0 _glesMultiTexCoord0
08-20 12:37:03.998: D/Unity(12066): in vec4 _glesMultiTexCoord0;
08-20 12:37:03.998: D/Unity(12066): #line 151
08-20 12:37:03.998: D/Unity(12066): struct v2f_vertex_lit {
08-20 12:37:03.998: D/Unity(12066):     highp vec2 uv;
08-20 12:37:03.998: D/Unity(12066):     lowp vec4 diff;
08-20 12:37:03.998: D/Unity(12066):     lowp vec4 spec;
08-20 12:37:03.998: D/Unity(12066): };
08-20 12:37:03.998: D/Unity(12066): #line 187
08-20 12:37:03.998: D/Unity(12066): struct v2f_img {
08-20 12:37:03.998: D/Unity(12066):     highp vec4 pos;
08-20 12:37:03.998: D/Unity(12066):     mediump vec2 uv;
08-20 12:37:03.998: D/Unity(12066): };
08-20 12:37:03.998: D/Unity(12066): #line 181
08-20 12:37:03.998: D/Unity(12066): struct appdata_img {
08-20 12:37:03.998: D/Unity(12066):     highp vec4 vertex;
08-20 12:37:03.998: D/Unity(12066):     mediump vec2 texcoord;
08-20 12:37:03.998: D/Unity(12066): };
08-20 12:37:03.998: D/Unity(12066): #line 325
08-20 12:37:03.998: D/Unity(12066): struct v2f {
08-20 12:37:03.998: D/Unity(12066):     highp vec4 vertex;
08-20 12:37:03.998: D/Unity(12066):     mediump vec4 color;
08-20 12:37:03.998: D/Unity(12066):     highp vec2 texcoord;
08-20 12:37:03.998: D/Unity(12066):     highp vec2 worldPos;
08-20 12:37:03.998: D/Unity(12066): };
08-20 12:37:03.998: D/Unity(12066): #line 318
08-20 12:37:03.998: D/Unity(12066): struct appdata_t {
08-20 12:37:03.998: D/Unity(12066):     highp vec4 vertex;
08-20 12:37:03.998: D/Unity(12066):     mediump vec4 color;
08-20 12:37:03.998: D/Unity(12066):     highp vec2 texcoord;
08-20 12:37:03.998: D/Unity(12066): };
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 _Time;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 _SinTime;
08-20 12:37:03.998: D/Unity(12066): #line 3
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 _CosTime;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_DeltaTime;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec3 _WorldSpaceCameraPos;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 _ProjectionParams;
08-20 12:37:03.998: D/Unity(12066): #line 7
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 _ScreenParams;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 _ZBufferParams;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_CameraWorldClipPlanes[6];
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 _WorldSpaceLightPos0;
08-20 12:37:03.998: D/Unity(12066): #line 11
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 _LightPositionRange;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_4LightPosX0;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_4LightPosY0;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_4LightPosZ0;
08-20 12:37:03.998: D/Unity(12066): #line 15
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_4LightAtten0;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_LightColor[8];
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_LightPosition[8];
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_LightAtten[8];
08-20 12:37:03.998: D/Unity(12066): #line 19
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_SpotDirection[8];
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_SHAr;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_SHAg;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_SHAb;
08-20 12:37:03.998: D/Unity(12066): #line 23
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_SHBr;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_SHBg;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_SHBb;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_SHC;
08-20 12:37:03.998: D/Unity(12066): #line 27
08-20 12:37:03.998: D/Unity(12066): uniform highp vec3 unity_LightColor0;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec3 unity_LightColor1;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec3 unity_LightColor2;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec3 unity_LightColor3;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_ShadowSplitSpheres[4];
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_ShadowSplitSqRadii;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_LightShadowBias;
08-20 12:37:03.998: D/Unity(12066): #line 31
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 _LightSplitsNear;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 _LightSplitsFar;
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 unity_World2Shadow[4];
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 _LightShadowData;
08-20 12:37:03.998: D/Unity(12066): #line 35
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_ShadowFadeCenterAndType;
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 glstate_matrix_mvp;
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 glstate_matrix_modelview0;
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 glstate_matrix_invtrans_modelview0;
08-20 12:37:03.998: D/Unity(12066): #line 39
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 _Object2World;
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 _World2Object;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 unity_Scale;
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 glstate_matrix_transpose_modelview0;
08-20 12:37:03.998: D/Unity(12066): #line 43
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 glstate_matrix_texture0;
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 glstate_matrix_texture1;
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 glstate_matrix_texture2;
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 glstate_matrix_texture3;
08-20 12:37:03.998: D/Unity(12066): #line 47
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 glstate_matrix_projection;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 glstate_lightmodel_ambient;
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 unity_MatrixV;
08-20 12:37:03.998: D/Unity(12066): uniform highp mat4 unity_MatrixVP;
08-20 12:37:03.998: D/Unity(12066): #line 51
08-20 12:37:03.998: D/Unity(12066): uniform lowp vec4 unity_ColorSpaceGrey;
08-20 12:37:03.998: D/Unity(12066): #line 77
08-20 12:37:03.998: D/Unity(12066): #line 82
08-20 12:37:03.998: D/Unity(12066): #line 87
08-20 12:37:03.998: D/Unity(12066): #line 91
08-20 12:37:03.998: D/Unity(12066): #line 96
08-20 12:37:03.998: D/Unity(12066): #line 120
08-20 12:37:03.998: D/Unity(12066): #line 137
08-20 12:37:03.998: D/Unity(12066): #line 158
08-20 12:37:03.998: D/Unity(12066): #line 166
08-20 12:37:03.998: D/Unity(12066): #line 193
08-20 12:37:03.998: D/Unity(12066): #line 206
08-20 12:37:03.998: D/Unity(12066): #line 215
08-20 12:37:03.998: D/Unity(12066): #line 220
08-20 12:37:03.998: D/Unity(12066): #line 229
08-20 12:37:03.998: D/Unity(12066): #line 234
08-20 12:37:03.998: D/Unity(12066): #line 243
08-20 12:37:03.998: D/Unity(12066): #line 260
08-20 12:37:03.998: D/Unity(12066): #line 265
08-20 12:37:03.998: D/Unity(12066): #line 291
08-20 12:37:03.998: D/Unity(12066): #line 299
08-20 12:37:03.998: D/Unity(12066): #line 307
08-20 12:37:03.998: D/Unity(12066): #line 311
08-20 12:37:03.998: D/Unity(12066): #line 315
08-20 12:37:03.998: D/Unity(12066): uniform sampler2D _MainTex;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec4 _MainTex_ST;
08-20 12:37:03.998: D/Unity(12066): uniform highp vec2 _ClipSharpness = vec2( 20.0, 20.0);
08-20 12:37:03.998: D/Unity(12066): #line 333
08-20 12:37:03.998: D/Unity(12066): #line 342
08-20 12:37:03.998: D/Unity(12066): #line 333
08-20 12:37:03.998: D/Unity(12066): v2f vert( in appdata_t v ) {
08-20 12:37:03.998: D/Unity(12066):     v2f o;
08-20 12:37:03.998: D/Unity(12066):     o.vertex = (glstate_matrix_mvp * v.vertex);
08-20 12:37:03.998: D/Unity(12066):     #line 337
08-20 12:37:03.998: D/Unity(12066):     o.color = v.color;
08-20 12:37:03.998: D/Unity(12066):     o.texcoord = v.texcoord;
08-20 12:37:03.998: D/Unity(12066):     o.worldPos = ((v.vertex.xy.xy * _MainTex_ST.xy) + _MainTex_ST.zw);
08-20 12:37:03.998: D/Unity(12066):     return o;
08-20 12:37:03.998: D/Unity(12066): }
08-20 12:37:03.998: D/Unity(12066): out mediump vec4 xlv_COLOR;
08-20 12:37:03.998: D/Unity(12066): out highp vec2 xlv_TEXCOORD0;
08-20 12:37:03.998: D/Unity(12066): out highp vec2 xlv_TEXCOORD1;
08-20 12:37:03.998: D/Unity(12066): void main() {
08-20 12:37:03.998: D/Unity(12066):     v2f xl_retval;
08-20 12:37:03.998: D/Unity(12066):     appdata_t xlt_v;
08-20 12:37:03.998: D/Unity(12066):     xlt_v.vertex = vec4(gl_Vertex);
08-20 12:37:03.998: D/Unity(12066):     xlt_v.color = vec4(gl_Color);
08-20 12:37:03.998: D/Unity(12066):     xlt_v.texcoord = vec2(gl_MultiTexCoord0);
08-20 12:37:03.998: D/Unity(12066):     xl_retval = vert( xlt_v);
08-20 12:37:03.998: D/Unity(12066):     gl_Position = vec4(xl_retval.vertex);
08-20 12:37:03.998: D/Unity(12066):     xlv_COLOR = vec4(xl_retval.color);
08-20 12:37:03.998: D/Unity(12066):     xlv_TEXCOORD0 = vec2(xl_retval.texcoord);
08-20 12:37:03.998: D/Unity(12066):     xlv_TEXCOORD1 = vec2(xl_retval.worldPos);
08-20 12:37:03.998: D/Unity(12066): }
08-20 12:37:03.998: E/Unity(12066): -------- GLSL error: WARNING: 0:7: 'float' : The type is missing precision qualifier
08-20 12:37:03.998: E/Unity(12066): WARNING: 0:9: 'float' : The type is missing precision qualifier
08-20 12:37:03.998: E/Unity(12066): WARNING: 0:11: 'float' : The type is missing precision qualifier
08-20 12:37:03.998: E/Unity(12066): WARNING: 0:315: 'sampler2D' : The type is missing precision qualifier
08-20 12:37:03.998: E/Unity(12066): ERROR: 0:317: 'uniform' :  cannot initialize this type of qualifier 
08-20 12:37:03.998: E/Unity(12066): ERROR: 0:335: 'o' : undeclared identifier
08-20 12:37:03.998: E/Unity(12066): ERROR: 0:335: 'vertex' :  field selection requires structure, vector, or matrix on left hand side
08-20 12:37:03.998: E/Unity(12066): ERROR: 0:335: 'assign' :  cannot convert from '4-component vector of float' to 'float'
08-20 12:37:03.998: E/Unity(12066): ERROR: 0:337: 'color' :  field selection requires structure, vector, or matrix on left hand side
08-20 12:37:03.998: E/Unity(12066): ERROR: 0:337: 'assign' :  cannot convert from '4-component vector of float' to 'float'
08-20 12:37:03.998: E/Unity(12066): ERROR: 0:338: 'texcoord' :  field selection requires structure, vector, or matrix on left hand side
08-20 12:37:03.998: E/Unity(12066): ERROR: 0:338: 'assign' :  cannot convert from '2-component vector of float' to 'float'
08-20 12:37:03.998: E/Unity(12066): ERROR: 0:339: 'worldPos' :  field selection requires structure,
« Last Edit: August 19, 2014, 11:55:39 PM by sonicviz »

sonicviz

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 58
    • View Profile
Re: Unlit/Transparent Colored (SoftClip) Error
« Reply #1 on: August 19, 2014, 11:44:00 PM »
Solved it:
Problem was the v2f o declaration within v2f vert (appdata_t v)
By moving that to before v2f vert (appdata_t v) ir now works on ATOM aok.

Seems to be similar to iOS AOT issues with things needing to be declared explicitly.

Here's the modified shader in case anyone else comes across this issue.
Although Unity does not officially support ATOM they are growing market share quite rapidly.

Shader "Unlit/Transparent Colored (SoftClip)"
{
   Properties
   {
      _MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {}
   }

   SubShader
   {
      LOD 200

      Tags
      {
         "Queue" = "Transparent"
         "IgnoreProjector" = "True"
         "RenderType" = "Transparent"
      }
      
      Pass
      {
         Cull Off
         Lighting Off
         ZWrite Off
         Offset -1, -1
         Fog { Mode Off }
         ColorMask RGB
         AlphaTest Greater .01
         Blend SrcAlpha OneMinusSrcAlpha

         CGPROGRAM
         #pragma vertex vert
         #pragma fragment frag

         #include "UnityCG.cginc"

         sampler2D _MainTex;
         float4 _MainTex_ST;
         float2 _ClipSharpness = float2(20.0, 20.0);

         struct appdata_t
         {
            float4 vertex : POSITION;
            half4 color : COLOR;
            float2 texcoord : TEXCOORD0;
         };

         struct v2f
         {
            float4 vertex : POSITION;
            half4 color : COLOR;
            float2 texcoord : TEXCOORD0;
            float2 worldPos : TEXCOORD1;
         };

         v2f o;
         
         v2f vert (appdata_t v)
         {
            //v2f o;
            o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
            o.color = v.color;
            o.texcoord = v.texcoord;
            o.worldPos = TRANSFORM_TEX(v.vertex.xy, _MainTex);
            return o;
         }

         half4 frag (v2f IN) : COLOR
         {
            // Softness factor
            float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos)) * _ClipSharpness;
         
            // Sample the texture
            half4 col = tex2D(_MainTex, IN.texcoord) * IN.color;
            col.a *= clamp( min(factor.x, factor.y), 0.0, 1.0);
            return col;
         }
         ENDCG
      }
   }
   
   SubShader
   {
      LOD 100

      Tags
      {
         "Queue" = "Transparent"
         "IgnoreProjector" = "True"
         "RenderType" = "Transparent"
      }
      
      Pass
      {
         Cull Off
         Lighting Off
         ZWrite Off
         Fog { Mode Off }
         ColorMask RGB
         AlphaTest Greater .01
         Blend SrcAlpha OneMinusSrcAlpha
         ColorMaterial AmbientAndDiffuse
         
         SetTexture [_MainTex]
         {
            Combine Texture * Primary
         }
      }
   }
}

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Android ATOM Device - Unlit/Transparent Colored (SoftClip) Error
« Reply #2 on: August 20, 2014, 03:23:45 PM »
I'm surprised that worked at all, to be honest. I have never seen the vertex output declared outside the function. Where did you see this used like that?

sonicviz

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 58
    • View Profile
Re: Android ATOM Device - Unlit/Transparent Colored (SoftClip) Error
« Reply #3 on: August 20, 2014, 08:26:41 PM »
I'm surprised that worked at all, to be honest. I have never seen the vertex output declared outside the function. Where did you see this used like that?

Nowhere, I just tried it to see if it worked and it did.

Reading the logcat gave me the sense that the error was declaration related and was similar to the AOT declaration issue that pops up on iOS (rightly or wrongly) so I just gave it a try and it worked.
Solved the issue on the device and works fine in the Editor and on ARM as well.
Isn't it just a global vs local declaration thing? Who said you can't do it?

I didn't see any errors or warnings in the console either so maybe Unity shader compile handles it just fine?
If so you may want to update the base NGUI shader (after confirm testing yourself;-)

Especially as DH confirmed official Intel Android chip support in the #Unite14 Keynote

Update:
Intel PR here
 IntelPR
Intel and Unity Collaborate to Extend Android Support across Intel-based Devices
http://newsroom.intel.com/community/intel_newsroom/blog/2014/08/20/intel-and-unity-collaborate-to-extend-android-support-across-intel-based-devices
https://software.intel.com/en-us/blogs/2014/08/15/unity-android-support

Unity* Resource Center for x86 Support
https://software.intel.com/en-us/articles/unity
« Last Edit: August 21, 2014, 03:58:45 AM by sonicviz »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Android ATOM Device - Unlit/Transparent Colored (SoftClip) Error
« Reply #4 on: August 22, 2014, 03:05:39 AM »
Well, good to know. I've made the changes to all the shaders at the time of my last reply btw. I wonder if this will fix them on GLES 3...