varying highp vec4 xlv_COLOR1;
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 LightMapLookup;
uniform sampler2D LightMap;
uniform sampler2D StudsMap;
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 Lamp0Color;
uniform highp vec3 Lamp0Dir;
void main ()
{
  highp vec4 oColor0_1;
  highp vec4 studs_2;
  lowp vec4 tmpvar_3;
  tmpvar_3 = texture2D (StudsMap, xlv_TEXCOORD1.xy);
  studs_2 = tmpvar_3;
  highp vec3 tmpvar_4;
  tmpvar_4 = mix (xlv_COLOR0.xyz, studs_2.xyz, studs_2.www);
  highp vec4 tmpvar_5;
  tmpvar_5.xyz = tmpvar_4;
  tmpvar_5.w = xlv_COLOR0.w;
  highp vec3 tmpvar_6;
  tmpvar_6 = abs((xlv_TEXCOORD2.xyz - LightConfig2.xyz));
  highp vec3 t_7;
  t_7.x = float((tmpvar_6.x >= LightConfig3.x));
  t_7.y = float((tmpvar_6.y >= LightConfig3.y));
  t_7.z = float((tmpvar_6.z >= LightConfig3.z));
  highp float tmpvar_8;
  tmpvar_8 = min (dot (t_7, vec3(1.0, 1.0, 1.0)), 1.0);
  highp vec4 s1_9;
  highp vec4 s0_10;
  highp vec4 offsets_11;
  lowp vec4 tmpvar_12;
  tmpvar_12 = texture2D (LightMapLookup, xlv_TEXCOORD2.xy);
  offsets_11 = tmpvar_12;
  highp vec2 tmpvar_13;
  tmpvar_13 = (xlv_TEXCOORD2.yz * 0.125);
  highp vec2 tmpvar_14;
  tmpvar_14 = (tmpvar_13 - (tmpvar_13 * tmpvar_8));
  lowp vec4 tmpvar_15;
  highp vec2 P_16;
  P_16 = (tmpvar_14 + offsets_11.xy);
  tmpvar_15 = texture2D (LightMap, P_16);
  s0_10 = tmpvar_15;
  lowp vec4 tmpvar_17;
  highp vec2 P_18;
  P_18 = (tmpvar_14 + offsets_11.zw);
  tmpvar_17 = texture2D (LightMap, P_18);
  s1_9 = tmpvar_17;
  highp vec4 tmpvar_19;
  tmpvar_19 = mix (mix (s0_10, s1_9, vec4(fract((xlv_TEXCOORD2.x * 64.0)))), LightBorder, vec4(tmpvar_8));
  oColor0_1.xyz = ((((AmbientColor + (xlv_COLOR1.xyz * tmpvar_19.w)) + tmpvar_19.xyz) * tmpvar_4) + (Lamp0Color * ((xlv_COLOR1.w * tmpvar_19.w) * pow (clamp (dot (normalize(xlv_TEXCOORD4.xyz), normalize((-(Lamp0Dir) + normalize(xlv_TEXCOORD3.xyz)))), 0.0, 1.0), xlv_TEXCOORD4.w))));
  oColor0_1.w = tmpvar_5.w;
  highp vec2 tmpvar_20;
  tmpvar_20 = min (xlv_TEXCOORD0.wz, xlv_TEXCOORD1.wz);
  highp float tmpvar_21;
  tmpvar_21 = (min (tmpvar_20.x, tmpvar_20.y) / xlv_TEXCOORD3.w);
  oColor0_1.xyz = (oColor0_1.xyz * min (((min (((xlv_TEXCOORD3.w * OutlineBrightness.x) + OutlineBrightness.y), 1.0) * (1.5 - tmpvar_21)) + tmpvar_21), 1.0));
  oColor0_1.xyz = mix (FogColor, oColor0_1.xyz, vec3(clamp (xlv_TEXCOORD2.w, 0.0, 1.0)));
  gl_FragData[0] = oColor0_1;
}

