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 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 vec4 albedo_2;
  highp float tmpvar_3;
  tmpvar_3 = max ((1.0 - xlv_TEXCOORD3.w), 0.0);
  highp vec4 diffuse_4;
  highp vec4 tmpvar_5;
  lowp vec4 tmpvar_6;
  tmpvar_6 = texture2D (DiffuseMap, xlv_TEXCOORD0.xy);
  tmpvar_5 = tmpvar_6;
  diffuse_4.w = tmpvar_5.w;
  diffuse_4.xyz = mix (vec3(1.0, 1.0, 1.0), tmpvar_5.xyz, vec3(tmpvar_3));
  highp vec3 tmpvar_7;
  tmpvar_7 = (xlv_COLOR0.xyz * diffuse_4.xyz);
  highp vec4 tmpvar_8;
  lowp vec4 tmpvar_9;
  tmpvar_9 = texture2D (SpecularMap, xlv_TEXCOORD0.xy);
  tmpvar_8 = tmpvar_9;
  highp vec2 tmpvar_10;
  tmpvar_10 = mix (vec2(0.07, 22.0), ((tmpvar_8.xy * vec2(1.3, 128.0)) + vec2(0.0, 0.01)), vec2(tmpvar_3));
  highp vec4 tmpvar_11;
  tmpvar_11.xyz = tmpvar_7;
  tmpvar_11.w = xlv_COLOR0.w;
  albedo_2.w = tmpvar_11.w;
  highp vec3 tmpvar_12;
  tmpvar_12 = normalize(xlv_TEXCOORD4.xyz);
  highp float tmpvar_13;
  tmpvar_13 = dot (tmpvar_12, -(Lamp0Dir));
  highp vec3 tmpvar_14;
  tmpvar_14 = abs((xlv_TEXCOORD2.xyz - LightConfig2.xyz));
  highp vec3 t_15;
  t_15.x = float((tmpvar_14.x >= LightConfig3.x));
  t_15.y = float((tmpvar_14.y >= LightConfig3.y));
  t_15.z = float((tmpvar_14.z >= LightConfig3.z));
  highp float tmpvar_16;
  tmpvar_16 = min (dot (t_15, vec3(1.0, 1.0, 1.0)), 1.0);
  highp vec4 s1_17;
  highp vec4 s0_18;
  highp vec4 offsets_19;
  lowp vec4 tmpvar_20;
  tmpvar_20 = texture2D (LightMapLookup, xlv_TEXCOORD2.xy);
  offsets_19 = tmpvar_20;
  highp vec2 tmpvar_21;
  tmpvar_21 = (xlv_TEXCOORD2.yz * 0.125);
  highp vec2 tmpvar_22;
  tmpvar_22 = (tmpvar_21 - (tmpvar_21 * tmpvar_16));
  lowp vec4 tmpvar_23;
  highp vec2 P_24;
  P_24 = (tmpvar_22 + offsets_19.xy);
  tmpvar_23 = texture2D (LightMap, P_24);
  s0_18 = tmpvar_23;
  lowp vec4 tmpvar_25;
  highp vec2 P_26;
  P_26 = (tmpvar_22 + offsets_19.zw);
  tmpvar_25 = texture2D (LightMap, P_26);
  s1_17 = tmpvar_25;
  highp vec4 tmpvar_27;
  tmpvar_27 = mix (mix (s0_18, s1_17, vec4(fract((xlv_TEXCOORD2.x * 64.0)))), LightBorder, vec4(tmpvar_16));
  albedo_2.xyz = tmpvar_7;
  oColor0_1.xyz = ((((AmbientColor + (((max (tmpvar_13, 0.0) * Lamp0Color) + (max (-(tmpvar_13), 0.0) * Lamp1Color)) * tmpvar_27.w)) + tmpvar_27.xyz) * tmpvar_7) + (Lamp0Color * (((float((tmpvar_13 >= 0.0)) * tmpvar_10.x) * tmpvar_27.w) * pow (clamp (dot (tmpvar_12, normalize((-(Lamp0Dir) + normalize(xlv_TEXCOORD3.xyz)))), 0.0, 1.0), tmpvar_10.y))));
  oColor0_1.w = albedo_2.w;
  highp vec2 tmpvar_28;
  tmpvar_28 = min (xlv_TEXCOORD0.wz, xlv_TEXCOORD1.wz);
  highp float tmpvar_29;
  tmpvar_29 = (min (tmpvar_28.x, tmpvar_28.y) / xlv_TEXCOORD3.w);
  oColor0_1.xyz = (oColor0_1.xyz * min (((min (((xlv_TEXCOORD3.w * OutlineBrightness.x) + OutlineBrightness.y), 1.0) * (1.5 - tmpvar_29)) + tmpvar_29), 1.0));
  oColor0_1.xyz = mix (FogColor, oColor0_1.xyz, vec3(clamp (xlv_TEXCOORD2.w, 0.0, 1.0)));
  gl_FragData[0] = oColor0_1;
}

