#version 300 es out mediump vec4 _fragData; struct SurfaceOutput { lowp vec3 Albedo; lowp vec3 Normal; lowp vec3 Emission; mediump float Specular; lowp float Gloss; lowp float Alpha; }; struct Input { mediump vec2 uv_MainTex; }; struct v2f_surf { highp vec4 pos; mediump vec2 pack0; mediump vec3 viewDir; lowp vec3 lightDir; lowp vec3 vlight; }; uniform sampler2D _BumpMap; uniform lowp vec4 _LightColor0; uniform sampler2D _MainTex; uniform mediump float _Shininess; lowp vec3 UnpackNormal( in lowp vec4 packednormal ); void surf( in Input IN, inout SurfaceOutput o ); lowp vec4 LightingMobileBlinnPhong( in SurfaceOutput s, in lowp vec3 lightDir, in lowp vec3 halfDir, in lowp float atten ); lowp vec4 frag_surf( in v2f_surf IN ); lowp vec3 UnpackNormal( in lowp vec4 packednormal ) { return ((packednormal.xyz * 2.0) - 1.0); } void surf( in Input IN, inout SurfaceOutput o ) { lowp vec4 tex; tex = texture2D( _MainTex, IN.uv_MainTex); o.Albedo = tex.xyz ; o.Gloss = tex.w ; o.Alpha = tex.w ; o.Specular = _Shininess; o.Normal = UnpackNormal( texture2D( _BumpMap, IN.uv_MainTex)); } lowp vec4 LightingMobileBlinnPhong( in SurfaceOutput s, in lowp vec3 lightDir, in lowp vec3 halfDir, in lowp float atten ) { lowp float diff; lowp float nh; lowp float spec; lowp vec4 c; diff = max( 0.0, dot( s.Normal, lightDir)); nh = max( 0.0, dot( s.Normal, halfDir)); spec = (pow( nh, (s.Specular * 128.0)) * s.Gloss); c.xyz = ((((s.Albedo * diff) + spec) * _LightColor0.xyz ) * (atten * 2.0)); c.w = 0.0; return c; } lowp vec4 frag_surf( in v2f_surf IN ) { Input surfIN; SurfaceOutput o; lowp float atten; lowp vec4 c; surfIN.uv_MainTex = IN.pack0.xy ; o.Albedo = vec3( 0.0); o.Emission = vec3( 0.0); o.Specular = 0.0; o.Alpha = 0.0; o.Gloss = 0.0; surf( surfIN, o); atten = 1.0; c = vec4( 0.0); c = LightingMobileBlinnPhong( o, IN.lightDir, IN.viewDir, atten); c.xyz += (o.Albedo * IN.vlight); return c; } in mediump vec2 xlv_TEXCOORD0; in mediump vec3 xlv_TEXCOORD1; in lowp vec3 xlv_TEXCOORD2; in lowp vec3 xlv_TEXCOORD3; void main() { lowp vec4 xl_retval; v2f_surf xlt_IN; xlt_IN.pos = vec4(0.0); xlt_IN.pack0 = vec2( xlv_TEXCOORD0); xlt_IN.viewDir = vec3( xlv_TEXCOORD1); xlt_IN.lightDir = vec3( xlv_TEXCOORD2); xlt_IN.vlight = vec3( xlv_TEXCOORD3); xl_retval = frag_surf( xlt_IN); _fragData = vec4( xl_retval); }