varying highp vec4 xlv_TEXCOORD4;
varying highp vec4 xlv_TEXCOORD3;
varying highp vec4 xlv_TEXCOORD2;
varying highp vec4 xlv_COLOR0;
varying highp vec4 xlv_TEXCOORD1;
varying highp vec4 xlv_TEXCOORD0;
uniform sampler2D SpecularMap;
uniform samplerCube EnvironmentMap;
uniform sampler2D DiffuseMap;
uniform sampler2D LightMapLookup;
uniform sampler2D LightMap;
uniform highp vec2 OutlineBrightness;
uniform highp vec4 LightBorder;
uniform highp vec4 LightConfig3;
uniform highp vec4 LightConfig2;
uniform highp vec3 FogColor;
uniform highp vec3 AmbientColor;
uniform highp vec3 Lamp1Color;
uniform highp vec3 Lamp0Color;
uniform highp vec3 Lamp0Dir;
void main ()
{
  highp vec4 oColor0_1;
  highp vec3 reflection_2;
  highp vec4 albedo_3;
  highp float tmpvar_4;
  tmpvar_4 = max ((1.0 - xlv_TEXCOORD3.w), 0.0);
  highp vec4 diffuse_5;
  highp vec4 tmpvar_6;
  lowp vec4 tmpvar_7;
  tmpvar_7 = texture2D (DiffuseMap, xlv_TEXCOORD0.xy);
  tmpvar_6 = tmpvar_7;
  diffuse_5.w = tmpvar_6.w;
  diffuse_5.xyz = mix (vec3(1.0, 1.0, 1.0), tmpvar_6.xyz, vec3(tmpvar_4));
  highp vec3 tmpvar_8;
  tmpvar_8 = (xlv_COLOR0.xyz * diffuse_5.xyz);
  highp vec4 tmpvar_9;
  lowp vec4 tmpvar_10;
  tmpvar_10 = texture2D (SpecularMap, xlv_TEXCOORD0.xy);
  tmpvar_9 = tmpvar_10;
  highp vec2 tmpvar_11;
  tmpvar_11 = mix (vec2(0.7, 54.0), ((tmpvar_9.xy * vec2(1.0, 128.0)) + vec2(0.0, 0.01)), vec2(tmpvar_4));
  highp vec4 tmpvar_12;
  tmpvar_12.xyz = tmpvar_8;
  tmpvar_12.w = xlv_COLOR0.w;
  albedo_3.w = tmpvar_12.w;
  highp vec3 tmpvar_13;
  tmpvar_13 = normalize(xlv_TEXCOORD4.xyz);
  highp float tmpvar_14;
  tmpvar_14 = dot (tmpvar_13, -(Lamp0Dir));
  highp vec3 tmpvar_15;
  tmpvar_15 = abs((xlv_TEXCOORD2.xyz - LightConfig2.xyz));
  highp vec3 t_16;
  t_16.x = float((tmpvar_15.x >= LightConfig3.x));
  t_16.y = float((tmpvar_15.y >= LightConfig3.y));
  t_16.z = float((tmpvar_15.z >= LightConfig3.z));
  highp float tmpvar_17;
  tmpvar_17 = min (dot (t_16, vec3(1.0, 1.0, 1.0)), 1.0);
  highp vec4 s1_18;
  highp vec4 s0_19;
  highp vec4 offsets_20;
  lowp vec4 tmpvar_21;
  tmpvar_21 = texture2D (LightMapLookup, xlv_TEXCOORD2.xy);
  offsets_20 = tmpvar_21;
  highp vec2 tmpvar_22;
  tmpvar_22 = (xlv_TEXCOORD2.yz * 0.125);
  highp vec2 tmpvar_23;
  tmpvar_23 = (tmpvar_22 - (tmpvar_22 * tmpvar_17));
  lowp vec4 tmpvar_24;
  highp vec2 P_25;
  P_25 = (tmpvar_23 + offsets_20.xy);
  tmpvar_24 = texture2D (LightMap, P_25);
  s0_19 = tmpvar_24;
  lowp vec4 tmpvar_26;
  highp vec2 P_27;
  P_27 = (tmpvar_23 + offsets_20.zw);
  tmpvar_26 = texture2D (LightMap, P_27);
  s1_18 = tmpvar_26;
  highp vec4 tmpvar_28;
  tmpvar_28 = mix (mix (s0_19, s1_18, vec4(fract((xlv_TEXCOORD2.x * 64.0)))), LightBorder, vec4(tmpvar_17));
  highp vec3 tmpvar_29;
  highp vec3 i_30;
  i_30 = -(xlv_TEXCOORD3.xyz);
  tmpvar_29 = (i_30 - (2.0 * (dot (tmpvar_13, i_30) * tmpvar_13)));
  lowp vec3 tmpvar_31;
  tmpvar_31 = textureCube (EnvironmentMap, tmpvar_29).xyz;
  reflection_2 = tmpvar_31;
  albedo_3.xyz = mix (tmpvar_8, reflection_2, vec3(((tmpvar_9.y * tmpvar_4) * 0.2)));
  oColor0_1.xyz = ((((AmbientColor + (((max (tmpvar_14, 0.0) * Lamp0Color) + (max (-(tmpvar_14), 0.0) * Lamp1Color)) * tmpvar_28.w)) + tmpvar_28.xyz) * albedo_3.xyz) + (Lamp0Color * (((float((tmpvar_14 >= 0.0)) * tmpvar_11.x) * tmpvar_28.w) * pow (clamp (dot (tmpvar_13, normalize((-(Lamp0Dir) + normalize(xlv_TEXCOORD3.xyz)))), 0.0, 1.0), tmpvar_11.y))));
  oColor0_1.w = albedo_3.w;
  highp vec2 tmpvar_32;
  tmpvar_32 = min (xlv_TEXCOORD0.wz, xlv_TEXCOORD1.wz);
  highp float tmpvar_33;
  tmpvar_33 = (min (tmpvar_32.x, tmpvar_32.y) / xlv_TEXCOORD3.w);
  oColor0_1.xyz = (oColor0_1.xyz * min (((min (((xlv_TEXCOORD3.w * OutlineBrightness.x) + OutlineBrightness.y), 1.0) * (1.5 - tmpvar_33)) + tmpvar_33), 1.0));
  oColor0_1.xyz = mix (FogColor, oColor0_1.xyz, vec3(clamp (xlv_TEXCOORD2.w, 0.0, 1.0)));
  gl_FragData[0] = oColor0_1;
}

