varying highp vec3 xlv_TEXCOORD6;
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 NormalDetailMap;
uniform sampler2D NormalMap;
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 vec3 normal_3;
  highp vec4 studs_4;
  lowp vec4 tmpvar_5;
  tmpvar_5 = texture2D (DiffuseMap, xlv_TEXCOORD1.xy);
  studs_4 = tmpvar_5;
  lowp vec4 tmpvar_6;
  tmpvar_6 = texture2D (NormalMap, xlv_TEXCOORD1.xy);
  highp vec3 tmpvar_7;
  highp vec4 value_8;
  value_8 = tmpvar_6;
  tmpvar_7 = ((value_8.xyz * 2.0) - 1.0);
  normal_3.z = tmpvar_7.z;
  lowp vec4 tmpvar_9;
  tmpvar_9 = texture2D (NormalDetailMap, xlv_TEXCOORD0.xy);
  highp vec4 value_10;
  value_10 = tmpvar_9;
  normal_3.xy = (tmpvar_7.xy + (((value_10.xyz * 2.0) - 1.0).xy * max ((xlv_COLOR0.w - 0.5), 0.0)));
  normal_3.xy = (normal_3.xy * max ((1.0 - xlv_TEXCOORD3.w), 0.0));
  highp vec3 tmpvar_11;
  tmpvar_11 = ((xlv_COLOR0.xyz * studs_4.xyz) * 2.0);
  highp vec4 tmpvar_12;
  tmpvar_12.xyz = tmpvar_11;
  tmpvar_12.w = xlv_COLOR0.w;
  albedo_2.w = tmpvar_12.w;
  highp vec3 tmpvar_13;
  tmpvar_13 = normalize((((normal_3.x * xlv_TEXCOORD6) + (normal_3.y * ((xlv_TEXCOORD4.yzx * xlv_TEXCOORD6.zxy) - (xlv_TEXCOORD4.zxy * xlv_TEXCOORD6.yzx)))) + (tmpvar_7.z * 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));
  albedo_2.xyz = tmpvar_11;
  oColor0_1.xyz = ((((AmbientColor + (((max (tmpvar_14, 0.0) * Lamp0Color) + (max (-(tmpvar_14), 0.0) * Lamp1Color)) * tmpvar_28.w)) + tmpvar_28.xyz) * tmpvar_11) + (Lamp0Color * (((float((tmpvar_14 >= 0.0)) * 0.4) * tmpvar_28.w) * pow (clamp (dot (tmpvar_13, normalize((-(Lamp0Dir) + normalize(xlv_TEXCOORD3.xyz)))), 0.0, 1.0), 9.0))));
  oColor0_1.w = albedo_2.w;
  highp vec2 tmpvar_29;
  tmpvar_29 = min (xlv_TEXCOORD0.wz, xlv_TEXCOORD1.wz);
  highp float tmpvar_30;
  tmpvar_30 = (min (tmpvar_29.x, tmpvar_29.y) / xlv_TEXCOORD3.w);
  oColor0_1.xyz = (oColor0_1.xyz * min (((min (((xlv_TEXCOORD3.w * OutlineBrightness.x) + OutlineBrightness.y), 1.0) * (1.5 - tmpvar_30)) + tmpvar_30), 1.0));
  oColor0_1.xyz = mix (FogColor, oColor0_1.xyz, vec3(clamp (xlv_TEXCOORD2.w, 0.0, 1.0)));
  gl_FragData[0] = oColor0_1;
}

