uniform float sunAngle;

float timeVal = sunAngle;

struct Time{
    float sunrise;
    float noon;
    float sunset;
    float night;
};

Time times = Time(((clamp(timeVal, 0.96, 1.00)-0.96) / 0.04 + 1-(clamp(timeVal, 0.02, 0.15)-0.02) / 0.13),((clamp(timeVal, 0.02, 0.15)-0.02) / 0.13   - (clamp(timeVal, 0.35, 0.48)-0.35) / 0.13),((clamp(timeVal, 0.35, 0.48)-0.35) / 0.13   - (clamp(timeVal, 0.50, 0.53)-0.50) / 0.03),((clamp(timeVal, 0.50, 0.53)-0.50) / 0.03   - (clamp(timeVal, 0.96, 1.00)-0.96) / 0.03));

float byTime(float sunrise, float noon, float sunset, float night)
{
    return sunrise * times.sunrise + noon * times.noon + sunset * times.sunset + night * times.night;
}

vec2 byTime(vec2 sunrise, vec2 noon, vec2 sunset, vec2 night)
{
    return sunrise * times.sunrise + noon * times.noon + sunset * times.sunset + night * times.night;
}

vec3 byTime(vec3 sunrise, vec3 noon, vec3 sunset, vec3 night)
{
    return sunrise * times.sunrise + noon * times.noon + sunset * times.sunset + night * times.night;
}

vec4 byTime(vec4 sunrise, vec4 noon, vec4 sunset, vec4 night)
{
    return sunrise * times.sunrise + noon * times.noon + sunset * times.sunset + night * times.night;
}