 // Worley noise implementation source:
 // https://github.com/Erkaman/glsl-worley
 // modified a touch; we only care about F1, so just return that in our 3D worley impl
-
 vec3 permute( vec3 x ) {
     return mod( ( 34.0 * x + 1.0 ) * x, 289.0 );
 }

const   float cloud_speed = 1.0;

const   vec3  cloud_base_color = vec3( 0.2, 0.3, 0.5 );

// noise functions by Inigo Quilez
float hash(float n) { return fract(sin(n) * 1e4); }

         + vec3( 0.8, 0.9, 1.0 ) * 0.40 * pow( sun_body, ( 1.0 - sun_flare_size ) * 100.0 );
}

/*
 * Henyey-Greenstein phase function for scattering
 *
 * q: the cosine (dot product) between incident (light to cloud pos) and scattered (cloud to eye pos) ray
 *
 */ 
float hg( float q )
{
    float g = 0.5;
    float t1 = 1.0 / ( 4.0 * PI );
    float gsq = g * g;
    float num = 1.0 - gsq;
    float denom = pow( ( 1.0 + gsq - 2.0 * g * q ), 1.5 );

    return t1 * ( num / denom );
}

vec4 clouds( vec3 v )
{
    vec2 ofs = vec2( uTime * cloud_speed * 80.0, uTime * cloud_speed * 60.0 );
    vec4 acc = vec4( 0, 0, 0, 0 ); // this is the final color value we return

    // early exit if we're beneath a certain threshold
    // this doesn't seem to save any frames, though
