// __multiversion__
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.

#include "uniformWorldConstants.h"
#include "uniformShaderConstants.h"
#include "fragmentVersionSimple.h"
#include ".renderchunks.h"

in highp vec3 pos;
in vec4 cloudColor;
in vec4 cloudColor2;

void main(){

vec4 result = skyColor(pos,FOG_COLOR, CURRENT_COLOR);
float rn = smoothstep(.55, .3, FOG_CONTROL.x);

float rd = length(pos.xz); highp vec3 p = pos; vec4 cc = cloudColor;
float cm = mix(fbm(p.xz*1.0),0.0,rn);

float layer = 0.0, ya = 1.0, ya2 = ya;

for(int i = 0; i < 5; i++)
{
if(cm>0.){
layer += (ya * max(cm-fbm(p.xz*0.95),0.)) * 0.1;
p /= 1.02;
layer += ya * sin(layer * 2.0);
   }
cc *= mix(0.9,0.975,layer * pow(length(p.xz) * .8, 0.7));
}

gl_FragColor = mix(result, cc, cm*1.4*(1.0-clamp(rd*1.3,0.0,1.0)));

}