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;
uniform samplerCube EnvironmentMap;
uniform sampler2D LightMapLookup;
uniform sampler2D LightMap;
uniform sampler2D StudsMap;
uniform highp float Reflectance;
uniform highp vec4 LightBorder;
uniform highp vec4 LightConfig3;
uniform highp vec4 LightConfig2;
uniform highp vec3 FogColor;
uniform highp vec3 AmbientColor;
uniform highp vec3 Lamp0Color;
void main ()
{
  highp vec4 oColor0_1;
  highp vec3 reflection_2;
  highp vec4 albedo_3;
  highp vec4 studs_4;
  lowp vec4 tmpvar_5;
  tmpvar_5 = texture2D (StudsMap, xlv_TEXCOORD1.xy);
  studs_4 = tmpvar_5;
  highp vec4 tmpvar_6;
  tmpvar_6.xyz = mix (xlv_COLOR0.xyz, studs_4.xyz, studs_4.www);
  tmpvar_6.w = xlv_COLOR0.w;
  albedo_3.w = tmpvar_6.w;
  highp vec3 tmpvar_7;
  tmpvar_7 = abs((xlv_TEXCOORD2.xyz - LightConfig2.xyz));
  highp vec3 t_8;
  t_8.x = float((tmpvar_7.x >= LightConfig3.x));
  t_8.y = float((tmpvar_7.y >= LightConfig3.y));
  t_8.z = float((tmpvar_7.z >= LightConfig3.z));
  highp float tmpvar_9;
  tmpvar_9 = min (dot (t_8, vec3(1.0, 1.0, 1.0)), 1.0);
  highp vec4 s1_10;
  highp vec4 s0_11;
  highp vec4 offsets_12;
  lowp vec4 tmpvar_13;
  tmpvar_13 = texture2D (LightMapLookup, xlv_TEXCOORD2.xy);
  offsets_12 = tmpvar_13;
  highp vec2 tmpvar_14;
  tmpvar_14 = (xlv_TEXCOORD2.yz * 0.125);
  highp vec2 tmpvar_15;
  tmpvar_15 = (tmpvar_14 - (tmpvar_14 * tmpvar_9));
  lowp vec4 tmpvar_16;
  highp vec2 P_17;
  P_17 = (tmpvar_15 + offsets_12.xy);
  tmpvar_16 = texture2D (LightMap, P_17);
  s0_11 = tmpvar_16;
  lowp vec4 tmpvar_18;
  highp vec2 P_19;
  P_19 = (tmpvar_15 + offsets_12.zw);
  tmpvar_18 = texture2D (LightMap, P_19);
  s1_10 = tmpvar_18;
  highp vec4 tmpvar_20;
  tmpvar_20 = mix (mix (s0_11, s1_10, vec4(fract((xlv_TEXCOORD2.x * 64.0)))), LightBorder, vec4(tmpvar_9));
  highp vec3 tmpvar_21;
  highp vec3 i_22;
  i_22 = -(xlv_TEXCOORD3.xyz);
  tmpvar_21 = (i_22 - (2.0 * (dot (xlv_TEXCOORD4.xyz, i_22) * xlv_TEXCOORD4.xyz)));
  lowp vec3 tmpvar_23;
  tmpvar_23 = textureCube (EnvironmentMap, tmpvar_21).xyz;
  reflection_2 = tmpvar_23;
  albedo_3.xyz = mix (tmpvar_6.xyz, reflection_2, vec3(Reflectance));
  oColor0_1.xyz = ((((AmbientColor + (xlv_COLOR1.xyz * tmpvar_20.w)) + tmpvar_20.xyz) * albedo_3.xyz) + (Lamp0Color * (xlv_COLOR1.w * tmpvar_20.w)));
  oColor0_1.w = albedo_3.w;
  oColor0_1.xyz = mix (FogColor, oColor0_1.xyz, vec3(clamp (xlv_TEXCOORD2.w, 0.0, 1.0)));
  gl_FragData[0] = oColor0_1;
}

