varying highp vec2 xlv_TEXCOORD4;
varying highp vec3 xlv_TEXCOORD3;
varying highp vec3 xlv_TEXCOORD2;
varying highp vec4 xlv_TEXCOORD1;
varying highp vec3 xlv_TEXCOORD0;
uniform sampler2D LightMapLookup;
uniform sampler2D LightMap;
uniform samplerCube EnvMap;
uniform sampler2D NormalMap2;
uniform sampler2D NormalMap1;
uniform highp vec3 Lamp0Color;
uniform highp vec3 Lamp0Dir;
uniform highp vec4 LightBorder;
uniform highp vec4 LightConfig3;
uniform highp vec4 LightConfig2;
uniform highp vec4 AmbientColor;
uniform highp vec3 FogColor;
uniform highp vec4 WaterColor;
uniform highp vec4 CameraPosition;
uniform highp vec4 nmAnimLerp;
void main ()
{
  highp vec3 normal_1;
  highp vec4 nm2_2;
  highp vec4 nm1_3;
  lowp vec4 tmpvar_4;
  tmpvar_4 = texture2D (NormalMap1, xlv_TEXCOORD0.xy);
  nm1_3 = tmpvar_4;
  lowp vec4 tmpvar_5;
  tmpvar_5 = texture2D (NormalMap2, xlv_TEXCOORD0.xy);
  nm2_2 = tmpvar_5;
  highp vec4 tmpvar_6;
  tmpvar_6 = mix (nm1_3, nm2_2, nmAnimLerp.xxxx);
  normal_1.z = tmpvar_6.z;
  normal_1.xy = ((2.0 * tmpvar_6.wy) - 1.0);
  normal_1.z = sqrt((1.001 - min (dot (normal_1.xy, normal_1.xy), 1.0)));
  highp vec3 tmpvar_7;
  tmpvar_7 = normalize((CameraPosition.xyz - xlv_TEXCOORD1.xyz));
  highp vec3 tmpvar_8;
  tmpvar_8 = abs((xlv_TEXCOORD3 - LightConfig2.xyz));
  highp vec3 t_9;
  t_9.x = float((tmpvar_8.x >= LightConfig3.x));
  t_9.y = float((tmpvar_8.y >= LightConfig3.y));
  t_9.z = float((tmpvar_8.z >= LightConfig3.z));
  highp float tmpvar_10;
  tmpvar_10 = min (dot (t_9, vec3(1.0, 1.0, 1.0)), 1.0);
  highp vec4 s1_11;
  highp vec4 s0_12;
  highp vec4 offsets_13;
  lowp vec4 tmpvar_14;
  tmpvar_14 = texture2D (LightMapLookup, xlv_TEXCOORD3.xy);
  offsets_13 = tmpvar_14;
  highp vec2 tmpvar_15;
  tmpvar_15 = (xlv_TEXCOORD3.yz * 0.125);
  highp vec2 tmpvar_16;
  tmpvar_16 = (tmpvar_15 - (tmpvar_15 * tmpvar_10));
  lowp vec4 tmpvar_17;
  highp vec2 P_18;
  P_18 = (tmpvar_16 + offsets_13.xy);
  tmpvar_17 = texture2D (LightMap, P_18);
  s0_12 = tmpvar_17;
  lowp vec4 tmpvar_19;
  highp vec2 P_20;
  P_20 = (tmpvar_16 + offsets_13.zw);
  tmpvar_19 = texture2D (LightMap, P_20);
  s1_11 = tmpvar_19;
  highp vec4 tmpvar_21;
  tmpvar_21 = mix (mix (s0_12, s1_11, vec4(fract((xlv_TEXCOORD3.x * 64.0)))), LightBorder, vec4(tmpvar_10));
  lowp vec4 tmpvar_22;
  tmpvar_22 = textureCube (EnvMap, tmpvar_7);
  highp vec3 i_23;
  i_23 = -(-(Lamp0Dir));
  highp vec4 tmpvar_24;
  tmpvar_24.w = 1.0;
  tmpvar_24.xyz = mix (FogColor, ((mix ((WaterColor.xyz + (normal_1.z * 0.02)), mix (tmpvar_22, vec4(0.6175, 0.8075, 0.8835, 0.95), xlv_TEXCOORD4.xxxx).xyz, vec3(clamp (((-2.5 * abs(dot ((0.5 * (xlv_TEXCOORD2 + normal_1.xzy)), tmpvar_7))) + 0.78), 0.0, 1.0))) * ((Lamp0Color * tmpvar_21.w) + (tmpvar_21.xyz + AmbientColor.xyz))) + vec3(((pow (clamp (dot ((i_23 - (2.0 * (dot (normal_1.xzy, i_23) * normal_1.xzy))), tmpvar_7), 0.0, 1.0), 900.0) * clamp ((tmpvar_21.w - 0.4), 0.0, 1.0)) * xlv_TEXCOORD4.y))), xlv_TEXCOORD0.zzz);
  gl_FragData[0] = tmpvar_24;
}

