varying vec4 xlv_TEXCOORD5;
varying vec4 xlv_TEXCOORD4;
varying vec4 xlv_TEXCOORD3;
varying vec4 xlv_TEXCOORD2;
varying vec4 xlv_COLOR0;
varying vec4 xlv_TEXCOORD1;
varying vec4 xlv_TEXCOORD0;
uniform sampler3D NoiseMap;
uniform sampler2D NormalMap;
uniform sampler2D DiffuseMap;
uniform sampler3D LightMap;
uniform sampler2D StudsMap;
uniform vec2 OutlineBrightness;
uniform vec4 LightBorder;
uniform vec4 LightConfig3;
uniform vec4 LightConfig2;
uniform vec3 FogColor;
uniform vec3 AmbientColor;
uniform vec3 Lamp1Color;
uniform vec3 Lamp0Color;
uniform vec3 Lamp0Dir;
void main ()
{
  vec4 oColor0_1;
  vec4 albedo_2;
  vec2 tmpvar_3;
  tmpvar_3 = (xlv_TEXCOORD0.xy * 0.1);
  vec4 tmpvar_4;
  tmpvar_4.w = 0.0;
  tmpvar_4.xyz = clamp (mix (((texture2D (DiffuseMap, tmpvar_3).xyz + xlv_COLOR0.xyz) - vec3(0.31, 0.43, 0.146)), texture2D (NormalMap, tmpvar_3).xyz, vec3(clamp (((((((((texture3D (NoiseMap, (xlv_TEXCOORD5.zyx * 0.06)).x * 0.6) - (texture3D (NoiseMap, (xlv_TEXCOORD5.xyz * 0.27)).x * 0.4)) + (texture3D (NoiseMap, (xlv_TEXCOORD5.xyz * 0.012)).x * 0.3)) - 0.95) + 0.3) / 2.0) / 0.3) + 0.5), 0.0, 1.0))), 0.0, 1.0);
  vec4 tmpvar_5;
  tmpvar_5 = texture2D (StudsMap, xlv_TEXCOORD1.xy);
  vec4 tmpvar_6;
  tmpvar_6.xyz = mix (mix (xlv_COLOR0, tmpvar_4, vec4(clamp ((1.0 - xlv_TEXCOORD3.w), 0.0, 1.0))).xyz, tmpvar_5.xyz, tmpvar_5.www);
  tmpvar_6.w = xlv_COLOR0.w;
  albedo_2.w = tmpvar_6.w;
  vec3 tmpvar_7;
  tmpvar_7 = normalize(xlv_TEXCOORD4.xyz);
  float tmpvar_8;
  tmpvar_8 = dot (tmpvar_7, -(Lamp0Dir));
  vec3 tmpvar_9;
  tmpvar_9 = abs((xlv_TEXCOORD2.xyz - LightConfig2.xyz));
  vec3 t_10;
  t_10.x = float((tmpvar_9.x >= LightConfig3.x));
  t_10.y = float((tmpvar_9.y >= LightConfig3.y));
  t_10.z = float((tmpvar_9.z >= LightConfig3.z));
  float tmpvar_11;
  tmpvar_11 = clamp (dot (t_10, vec3(1.0, 1.0, 1.0)), 0.0, 1.0);
  vec4 tmpvar_12;
  tmpvar_12 = mix (texture3D (LightMap, (xlv_TEXCOORD2.yzx - (xlv_TEXCOORD2.yzx * tmpvar_11))), LightBorder, vec4(tmpvar_11));
  albedo_2.xyz = tmpvar_6.xyz;
  oColor0_1.xyz = ((((AmbientColor + (((clamp (tmpvar_8, 0.0, 1.0) * Lamp0Color) + (max (-(tmpvar_8), 0.0) * Lamp1Color)) * tmpvar_12.w)) + tmpvar_12.xyz) * tmpvar_6.xyz) + (Lamp0Color * (((float((tmpvar_8 >= 0.0)) * 0.1) * tmpvar_12.w) * pow (clamp (dot (tmpvar_7, normalize((-(Lamp0Dir) + normalize(xlv_TEXCOORD3.xyz)))), 0.0, 1.0), 50.0))));
  oColor0_1.w = albedo_2.w;
  vec2 tmpvar_13;
  tmpvar_13 = min (xlv_TEXCOORD0.wz, xlv_TEXCOORD1.wz);
  float tmpvar_14;
  tmpvar_14 = (min (tmpvar_13.x, tmpvar_13.y) / xlv_TEXCOORD3.w);
  oColor0_1.xyz = (oColor0_1.xyz * clamp (((clamp (((xlv_TEXCOORD3.w * OutlineBrightness.x) + OutlineBrightness.y), 0.0, 1.0) * (1.5 - tmpvar_14)) + tmpvar_14), 0.0, 1.0));
  oColor0_1.xyz = mix (FogColor, oColor0_1.xyz, vec3(clamp (xlv_TEXCOORD2.w, 0.0, 1.0)));
  gl_FragData[0] = oColor0_1;
}

