varying vec3 xlv_TEXCOORD6;
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 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;
  float tmpvar_3;
  tmpvar_3 = clamp ((1.0 - xlv_TEXCOORD3.w), 0.0, 1.0);
  vec3 tNorm_4;
  vec3 tmpvar_5;
  tmpvar_5 = (texture2D (NormalMap, (xlv_TEXCOORD5.xy * 0.6)).xyz - 0.5);
  tNorm_4.z = tmpvar_5.z;
  vec4 tmpvar_6;
  tmpvar_6.xy = dFdx(xlv_TEXCOORD5.yz);
  tmpvar_6.zw = dFdy(xlv_TEXCOORD5.yz);
  vec3 tmpvar_7;
  tmpvar_7 = (xlv_TEXCOORD5.xyz + texture3D (NoiseMap, (xlv_TEXCOORD5.xyz / 64.0)).xyz);
  float tmpvar_8;
  tmpvar_8 = (4.0 * sqrt(dot (tmpvar_7.yz, tmpvar_7.yz)));
  float tmpvar_9;
  tmpvar_9 = (tmpvar_8 + texture3D (NoiseMap, (vec3(tmpvar_8) / 32.0)).x);
  float tmpvar_10;
  tmpvar_10 = (tmpvar_9 - floor(tmpvar_9));
  float t_11;
  t_11 = max (min (((tmpvar_10 - 0.4) / 0.4), 1.0), 0.0);
  float t_12;
  t_12 = max (min (((tmpvar_10 - 0.83) / 0.17), 1.0), 0.0);
  float tmpvar_13;
  tmpvar_13 = mix (((t_11 * (t_11 * (3.0 - (2.0 * t_11)))) - (t_12 * (t_12 * (3.0 - (2.0 * t_12))))), 0.315, clamp (((sqrt(dot (tmpvar_6, tmpvar_6)) * 12.0) - 1.0), 0.0, 1.0));
  tNorm_4.xy = (tmpvar_5.xy * (clamp ((1.05 - abs(xlv_TEXCOORD5.w)), 0.0, 1.0) * tmpvar_3));
  vec4 tmpvar_14;
  tmpvar_14 = texture2D (StudsMap, xlv_TEXCOORD1.xy);
  vec4 tmpvar_15;
  tmpvar_15.xyz = mix ((xlv_COLOR0.xyz + ((0.1 * (0.315 - tmpvar_13)) * tmpvar_3)), tmpvar_14.xyz, tmpvar_14.www);
  tmpvar_15.w = xlv_COLOR0.w;
  albedo_2.w = tmpvar_15.w;
  vec3 tmpvar_16;
  tmpvar_16 = normalize((((tNorm_4.x * xlv_TEXCOORD6) + (tNorm_4.y * ((xlv_TEXCOORD4.yzx * xlv_TEXCOORD6.zxy) - (xlv_TEXCOORD4.zxy * xlv_TEXCOORD6.yzx)))) + (tmpvar_5.z * xlv_TEXCOORD4.xyz)));
  float tmpvar_17;
  tmpvar_17 = dot (tmpvar_16, -(Lamp0Dir));
  vec3 tmpvar_18;
  tmpvar_18 = abs((xlv_TEXCOORD2.xyz - LightConfig2.xyz));
  vec3 t_19;
  t_19.x = float((tmpvar_18.x >= LightConfig3.x));
  t_19.y = float((tmpvar_18.y >= LightConfig3.y));
  t_19.z = float((tmpvar_18.z >= LightConfig3.z));
  float tmpvar_20;
  tmpvar_20 = clamp (dot (t_19, vec3(1.0, 1.0, 1.0)), 0.0, 1.0);
  vec4 tmpvar_21;
  tmpvar_21 = mix (texture3D (LightMap, (xlv_TEXCOORD2.yzx - (xlv_TEXCOORD2.yzx * tmpvar_20))), LightBorder, vec4(tmpvar_20));
  albedo_2.xyz = tmpvar_15.xyz;
  oColor0_1.xyz = ((((AmbientColor + (((clamp (tmpvar_17, 0.0, 1.0) * Lamp0Color) + (max (-(tmpvar_17), 0.0) * Lamp1Color)) * tmpvar_21.w)) + tmpvar_21.xyz) * tmpvar_15.xyz) + (Lamp0Color * (((float((tmpvar_17 >= 0.0)) * mix (0.2696, mix (0.32, 0.16, tmpvar_13), tmpvar_3)) * tmpvar_21.w) * pow (clamp (dot (tmpvar_16, normalize((-(Lamp0Dir) + normalize(xlv_TEXCOORD3.xyz)))), 0.0, 1.0), 4.0))));
  oColor0_1.w = albedo_2.w;
  vec2 tmpvar_22;
  tmpvar_22 = min (xlv_TEXCOORD0.wz, xlv_TEXCOORD1.wz);
  float tmpvar_23;
  tmpvar_23 = (min (tmpvar_22.x, tmpvar_22.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_23)) + tmpvar_23), 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;
}

