Search Unity

Shader problem with android.

Discussion in 'Shaders' started by QingRuoChen, Aug 24, 2013.

  1. QingRuoChen

    QingRuoChen

    Joined:
    Jan 17, 2013
    Posts:
    4
    I am trying to get some characters rendering correctly when it was covering
    Code (csharp):
    1.  
    2. Shader "RimLight" {
    3.     Properties {
    4.         _MainTex ("Base (RGB)", 2D) = "" {}
    5.         _Color ("Color",color) = (1,1,1,1)
    6.         _Value("Light",range(0.01,5)) = 0.2
    7.     }
    8.     SubShader {
    9.          Tags { "Queue" = "Transparent" }//"RenderType"="Opaque" }
    10.          Pass
    11.          {
    12.             blend one oneminussrccolor
    13.             ZTest Greater
    14.             Lighting Off
    15.             ZWrite off
    16.             CGPROGRAM
    17. // Upgrade NOTE: excluded shader from DX11 and Xbox360; has structs without semantics (struct v2f members normal,dir)
    18. #pragma exclude_renderers d3d11 xbox360
    19.             #pragma vertex vert
    20.             #pragma fragment frag
    21.             #include "UnityCG.cginc"
    22.             sampler2D _MainTex;
    23.             half4 _Color;
    24.             float _Value;
    25.             struct input
    26.             {
    27.                 float4 pos:POSITION;
    28.                 float3 normal : NORMAL;
    29.             };
    30.             struct v2f
    31.             {
    32.                 float4 pos:POSITION;
    33.                 float3 normal;
    34.                 float3 dir;
    35.             };
    36.             v2f vert(input i)
    37.             {
    38.                 v2f v;
    39.                 v.pos = mul(UNITY_MATRIX_MVP,i.pos);
    40.                 v.dir = mul(UNITY_MATRIX_MV,i.pos).xyz;
    41.                 v.normal = i.normal;
    42.                 return v;
    43.             }
    44.             half4 frag(v2f v):Color
    45.             {
    46.                 half4 o ;
    47.                 half rim = 1.0 - saturate(dot (normalize(v.dir), v.normal));
    48.                 o = half4 (_Color.rgb * pow (rim, _Value),1);
    49.                 return o;
    50.             }
    51.             ENDCG
    52.         }
    53.          Pass
    54.          {
    55.             Lighting off
    56.             ZTest LEqual
    57.             Material
    58.             {
    59.                 Diffuse (1,1,1,1)
    60.                 Ambient (1,1,1,1)
    61.             }
    62.          
    63.             SetTexture [_MainTex] { combine texture }
    64.         }
    65.     }
    66.     fallBack "Diffuse"
    67. }
    68.  
    It works well on the PC.
    $2.png

    But it not work on android.
    $S30824-161015.jpg


    I do not know where is the problem. Any help and suggestion is greatly appreciated. thanks folks.
     
  2. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    350