
vec3 GetPseudoScattering(vec3 viewDir, vec3 lightDir, vec4 phases)
{
    float VoL = max(dot(viewDir, lightDir), 0.0);

    float scatter =
          pow(VoL, 6.0) * 0.25 +
          pow(VoL, 16.0) * 0.50 +
          pow(VoL, 64.0) * 1.20;


    float horizon = smoothstep(0.0, 0.5, 1.0 - max(viewDir.y, 0.0));

    

    vec3 scatterColor =
          vec3(1.0, 0.45, 0.20)  * phases.x +
          vec3(1.0, 0.302, 0.0) * phases.y +
          vec3(1.0, 0.7176, 0.0) * phases.z;

    return scatterColor* scatter  * horizon;
}
vec3 MoonScatter(vec3 viewDir, vec3 LightDir, vec4 phases){
     float VoL=max(dot(viewDir,LightDir),0.0);
     float scatter =pow(VoL, 2.0) * 0.25 +pow(VoL, 8.0) * 0.50+pow(VoL, 64.0) * 1.20;
     float horizon = smoothstep(0.0, 0.5, 1.0 - max(viewDir.y, 0.0));
     vec3 scatterColor=vec3(0.69, 0.67, 1.0)*phases.w;
     


     return scatterColor*scatter*SKY_SCATTER_STRENGTH*horizon;
}


vec3 GetSunDirection()
{
    return normalize(mat3(gbufferModelViewInverse) * normalize(sunPosition));
}

vec3 GetMoonDirection()
{
    return normalize(mat3(gbufferModelViewInverse) * normalize(moonPosition));
}


vec3 GetSunSkyLighting(vec3 sky, vec3 viewDir, vec3 sunDir, vec4 phases)
{
    float sunGlow = pow(max(dot(viewDir, sunDir), 0.0), SKY_SUN_GLOW_POWER);

    vec3 warm =
          vec3(1.00,0.55,0.25) * phases.x +
          vec3(1.0, 0.451, 0.0) * phases.y +
          vec3(1.00,0.42,0.18) * phases.z;

    sky += warm * sunGlow * SKY_SUN_GLOW_STRENGTH;

    float opposite = pow(max(dot(viewDir, -sunDir),0.0), SKY_OPPOSITE_GLOW_POWER);

    sky += vec3(0.08,0.12,0.25)
         * opposite
         * (phases.x + phases.z);

    return sky;
}
