const float pc_cirrusAltitude   = 4000.0;
const float pc_cirrusThickness  = 35.0;
const float pc_cirrusLowEdge    = pc_cirrusAltitude-pc_cirrusThickness/2;
const float pc_cirrusHighEdge   = pc_cirrusAltitude+pc_cirrusThickness/2;

float pc_cirrusShape(in vec3 pos) {
    const float size = 0.015;
    float tick      = frameTimeCounter*0.06;
    vec2 windTick   = tick*vec2(1.0, 0.0);

        pos.xz      = rotateCoord(pos.xz, pi*0.1);        
    vec3 pos2       = pos.xyz;
        pos2.xz     = rotateCoord(pos2.xz, -pi*0.1);

    float offset    = noise2D(pos.xz*vec2(0.4, 1.0), 0.12*size, windTick*0.9)*3.0;
        offset     += noise2D(pos.xz+offset*10.0, 0.34*size, windTick*1.2);
    
    vec3 posNoise   = pos+vec3(offset*20.0)*vec3(1.0, 1.0, 2.0);

    float lowFade   = smoothstep(pos.y, pc_cirrusLowEdge, pc_cirrusAltitude);
    float highFade  = 1.0-smoothstep(pos.y, pc_cirrusAltitude, pc_cirrusHighEdge);

    float shape     = perlin2D(posNoise.xz*vec2(0.25, 1.0), 0.4*size, windTick)*1.1;
        shape      -= worley2D(posNoise.xz*vec2(0.25, 1.0), 0.16*size, windTick*1.1)*0.8-0.4;
        shape       = abs(shape);
        shape      += perlin2D(posNoise.xz*vec2(0.25, 1.0), 2.9*size, windTick*1.3)*0.3;
        shape      += perlin2D(posNoise.xz*vec2(0.35, 1.0), 6.9*size, windTick*1.6)*0.1;
        shape      += worley2D(posNoise.xz*vec2(1.0, 0.1), 21.9*size, windTick*3.1)*0.06-0.03;

        shape      += worley2D(posNoise.xz*vec2(1.0, 0.1), 34.9*size, windTick*3.5)*0.05-0.025;

        #ifndef isReflectPass
            shape      += perlin2D(posNoise.xz*vec2(1.0, 0.4), 28.21*size*6, windTick*4.9)*0.014;
            shape      += noise2D(posNoise.xz, 21.87*size, -windTick*4.45)*0.02;
        #endif

        shape      -= 0.13;

        shape      += (pc_cirrusCoverage-1.0);

        #ifdef setBiomeEffects
            float biomeCoverage = -0.12*biomeCold + 0.15*biomeHot + 0.2*biomeDesert + 0.12*biomeTropic - 0.15*biomeSnow;
            shape      -= biomeCoverage;
        #endif

        shape      *= 1.4;

    float coverage  = shape;
        coverage   -= 1.0-lowFade;
        coverage   -= 1.0-highFade;

        coverage    = max(coverage, 0.0);

    return coverage*1.1;
}