uniform sampler2D StudsMap;
uniform sampler2D NormalMap;
uniform sampler3D NoiseMap;
uniform sampler3D LightMap;
uniform vec4 LightConfig1;
uniform vec4 LightBorder;
uniform vec3 Lamp1Color;
uniform vec3 Lamp0Dir;
uniform vec3 Lamp0Color;
uniform vec3 FogColor;
uniform vec3 AmbientColor;
void main ()
{
  vec4 tmpvar_1;
  tmpvar_1 = gl_TexCoord[2];
  vec4 tmpvar_2;
  tmpvar_2 = gl_TexCoord[4];
  vec4 tmpvar_3;
  tmpvar_3 = gl_TexCoord[5];
  vec4 tmpvar_4;
  tmpvar_4 = gl_TexCoord[6];
  vec4 oColor0_5;
  vec4 albedo_6;
  vec3 tmpvar_7;
  vec4 tmpvar_8;
  tmpvar_8 = texture2D (StudsMap, gl_TexCoord[1].xy);
  vec3 normal_9;
  vec3 tmpvar_10;
  tmpvar_10 = (texture2D (NormalMap, (gl_TexCoord[0].xy * 0.1)).xyz - 0.5);
  normal_9.xy = tmpvar_10.xy;
  normal_9.z = 2.0;
  tmpvar_7.z = normal_9.z;
  float tmpvar_11;
  tmpvar_11 = clamp (tmpvar_4.w, 0.0, 1.0);
  tmpvar_7.xy = (tmpvar_10.xy * (1.0 - tmpvar_11));
  vec3 tmpvar_12;
  tmpvar_12 = mix (mix (((gl_Color.xyz + (((texture3D (NoiseMap, ((tmpvar_3.xyz / 7.0) * 0.04)).xyz * (texture3D (NoiseMap, ((tmpvar_3.xyz / 7.0) * 0.3)).xyz + 0.2)) * 0.4) - 0.08)) * (0.9 + (0.4 * tmpvar_10.x))), gl_Color.xyz, vec3(tmpvar_11)), tmpvar_8.xyz, tmpvar_8.www);
  vec4 tmpvar_13;
  tmpvar_13.xyz = tmpvar_12;
  tmpvar_13.w = gl_Color.w;
  albedo_6.w = tmpvar_13.w;
  vec3 tmpvar_14;
  tmpvar_14 = normalize((((tmpvar_7.x * tmpvar_4.xyz) + (tmpvar_7.y * ((tmpvar_2.yzx * tmpvar_4.zxy) - (tmpvar_2.zxy * tmpvar_4.yzx)))) + (2.0 * tmpvar_2.xyz)));
  float tmpvar_15;
  tmpvar_15 = dot (tmpvar_14, -(Lamp0Dir));
  vec4 tmpvar_16;
  tmpvar_16.xyz = ((clamp (tmpvar_15, 0.0, 1.0) * Lamp0Color) + (max (-(tmpvar_15), 0.0) * Lamp1Color));
  tmpvar_16.w = (float((tmpvar_15 >= 0.0)) * 0.1);
  vec3 tmpvar_17;
  tmpvar_17 = clamp (tmpvar_1.xyz, 0.0, 1.0);
  vec3 tmpvar_18;
  tmpvar_18 = abs((tmpvar_17 - 0.5));
  vec4 tmpvar_19;
  tmpvar_19 = mix (LightBorder, texture3D (LightMap, (tmpvar_17 - LightConfig1.xyz)), vec4(float((0.49 >= max (tmpvar_18.x, max (tmpvar_18.y, tmpvar_18.z))))));
  albedo_6.xyz = tmpvar_12;
  oColor0_5.xyz = ((((AmbientColor + (tmpvar_16.xyz * tmpvar_19.w)) + tmpvar_19.xyz) * tmpvar_12) + (Lamp0Color * ((tmpvar_19.w * tmpvar_16.w) * pow (clamp (dot (tmpvar_14, normalize((-(Lamp0Dir) + normalize(gl_TexCoord[3].xyz)))), 0.0, 1.0), tmpvar_2.w))));
  oColor0_5.w = albedo_6.w;
  oColor0_5.xyz = mix (FogColor, oColor0_5.xyz, vec3(clamp (tmpvar_1.w, 0.0, 1.0)));
  gl_FragData[0] = oColor0_5;
}

