vec3 GetSkyColor(vec3 viewPos,vec3 lightCol, bool isReflection){
    vec3 sky=skyCol;
    vec3 nViewPos=normalize(viewPos);
    
    float NdotU=clamp(dot(nViewPos,upVec),0.,1.);
    float invNdotU=clamp(dot(nViewPos,-upVec)*1.015-.015,0.,1.);
    float NdotS=clamp(dot(nViewPos,sunVec)*.5+.5,0.,1.);
    
    float horizonExponent=3.*((1.-NdotS)*sunVisibility*(1.-rainStrength)*
    (1.-.5*timeBrightness))+HORIZON_DISTANCE;
    float horizon=pow(1.-NdotU,horizonExponent);
    horizon*=(.5*sunVisibility+.3)*(1-rainStrength*.75);
    
    float lightmix=NdotS*NdotS*(1.-NdotU)*pow(1.-timeBrightness,3.)+
    horizon*.075*timeBrightness;
    lightmix*=sunVisibility*(1.-rainStrength);
    
    #ifdef SKY_VANILLA
    sky=mix(fogCol,sky,NdotU);
    #endif
    
    #if SKY_GROUND > 0
    float groundFactor = 0.5 * (11.0 * rainStrength * rainStrength + 1.0) * 
                         (-5.0 * sunVisibility + 6.0);
    float ground = 1.0 - exp(-(groundFactor * FOG_DENSITY) / (invNdotU * 12.0));
    #if SKY_GROUND == 1
    if (!isReflection) ground = 1.0;
    #endif
    #else
    float ground = 1.0;
    #endif

    float mult=(.1*(1.+rainStrength)+horizon)*ground;
    
    sky=mix(
        sky*pow(max(1.-lightmix,0.),2.*sunVisibility),
        lightCol*sqrt(lightCol),
lightmix
)*sunVisibility+(lightNight*lightNight*.4);

vec3 weatherSky=weatherCol.rgb*weatherCol.rgb;
weatherSky*=GetLuminance(ambientCol/(weatherSky))*1.4;
sky=mix(sky,weatherSky,rainStrength)*mult;

return pow(sky,vec3(1.125));
}