#ifndef FOG_COLOR_UNIFORM
#define FOG_COLOR_UNIFORM
uniform vec3 fogColor;
#endif

vec4 getAmbientColor(float skyLight, float sunHeight) {
   #ifdef THE_END
      vec3 biome = max(fogColor, vec3(0.02));
      return vec4(mix(vec3(0.52, 0.50, 0.54), biome, 0.08), 1.0);
   #else
      vec4 ambient = texture2D(lightmap, vec2(AMBIENT_UV.s, skyLight));

      #ifdef OVERWORLD
         float x = ambient.g;
         float final = (((0.8494 * x + 0.9687) * x - 5.238) * x + 3.711) * x - 0.2864;

         final = max(0.0, final);

         ambient.rgb = mix(
            min(vec3(1.0), ambient.rgb + vec3(final) * clamp(0.2*sunHeight, 0.0, 1.0)),
            ambient.rgb,
            screenBrightness
         );
      #elif defined THE_NETHER
         float al = luma(ambient.rgb);
         float lift = mix(1.03, 0.99, smoothstep(0.18, 0.80, al));
         ambient.rgb *= lift * NETHER_AMBIENT;
      #endif

      return ambient;
   #endif
}
