//SETTINGS// uniform float timeScale = 0.25; uniform float cloudScale = 0.5; uniform float skyCover = 0.6; uniform float softness = 0.2; uniform float brightness = 0.1; uniform int noiseOctaves = 8; uniform float curlStrain = 3.0; uniform float cover = 0.35; //SETTINGS// float saturate(float num) { return clamp(num, 0.0, 1.0); } float noise(vec2 uv) { return (snoise(uv) + 1.0) / 2.0; } vec2 rotate(vec2 uv) { uv = uv + noise(uv * 0.2) * 0.005; float rot = curlStrain; float sinRot = sin(rot); float cosRot = cos(rot); mat2 rotMat = mat2(cosRot, -sinRot, sinRot, cosRot); return uv * rotMat; } float fbm(vec2 uv) { float rot = 1.57; float sinRot = sin(rot); float cosRot = cos(rot); float f = 0.0; float total = 0.0; float mul = 0.5; mat2 rotMat = mat2(cosRot, -sinRot, sinRot, cosRot); for (int i = 0; i < noiseOctaves; i++) { f += noise(uv + iGlobalTime * 0.15 * timeScale * (1.0 - mul)) * mul; total += mul; uv *= 3.0; uv = rotate(uv); mul *= 0.5; } return f / total; } // https://sites.google.com/site/justinscsstuff/object-intersection const vec3 SKY_NORMAL = vec3(0, 1, 0); const vec3 SKY_COLOR = vec3(0.05, 0.05, 0.07); const vec3 SKY_POSITION = vec3(0, 0.5, 0); vec3 getSkyboxColor() { vec3 normal = normalize(_normal); float nDotD = dot(SKY_NORMAL, normal); vec3 intersection = normal * (-dot(SKY_NORMAL, -SKY_POSITION) / nDotD); float fw = length(fwidth(intersection.xz)); if (nDotD < 0) { return vec3(SKY_COLOR) * max(pow(fw, 0.8) * 2.0, 0.5); } vec2 uv = intersection.xz; float bright = brightness*(1.8-cover); float color1 = fbm(uv-0.5+iGlobalTime*0.04*timeScale); float color2 = fbm(uv-10.5+iGlobalTime*0.02*timeScale); float clouds1 = smoothstep(1.0-cover,min((1.0-cover)+softness*2.0,1.0),color1); float clouds2 = smoothstep(1.0-cover,min((1.0-cover)+softness,1.0),color2); float cloudsFormComb = saturate(clouds1+clouds2) + pow(fw, 0.8) * 2.0; float cloudCol = saturate(saturate(1.0-pow(color1,1.2)*0.2)*bright); vec3 clouds1Color = vec3(cloudCol,cloudCol,cloudCol); vec3 clouds2Color = mix(clouds1Color,SKY_COLOR,0.25); vec3 cloudColComb = mix(clouds1Color,clouds2Color,saturate(clouds2-clouds1)); return mix(SKY_COLOR, cloudColComb, min(cloudsFormComb, 1.0)); }