// [1] Banding in games http://loopit.dk/banding_in_games.pdf

varying lowp vec3 v_uv;

uniform lowp samplerCube u_cubemap;
uniform lowp float u_opacity;
uniform highp float u_temporal_offset;
uniform highp vec3 u_sun_direction;

void main() {
    vec3 uv = v_uv;
    vec3 sky_color = textureCube(u_cubemap, uv).rgb;

#ifdef FOG
    // Apply fog contribution if enabled
    // Swizzle to put z-up (ignoring x-y mirror since fog does not depend on azimuth)
    sky_color = fog_apply_sky_gradient(v_uv.xzy, sky_color);
#endif

    // Dither [1]
    // sky_color.rgb = dither(sky_color.rgb, gl_FragCoord.xy + u_temporal_offset);
    gl_FragColor = vec4(sky_color * u_opacity, u_opacity);
#ifdef OVERDRAW_INSPECTOR
    gl_FragColor = vec4(1.0);
#endif
}
