1 in vec3 fragmentTextureCoordinates;
5 uniform float daylight;
6 uniform samplerCube texture0;
8 float reverseMix(float value, float min, float max)
10 return clamp((value - min) / (max - min), 0.0, 1.0);
13 float strengthen(float value, float exponent, float max)
15 return min((1.0 - pow(1.0 - value, exponent)) / (1.0 - pow(1.0 - max, exponent)), 1.0);
20 float height = normalize(fragmentTextureCoordinates).y;
22 vec4 topColor = texture(texture0, vec3(0.0, 1.0, 0.0));
23 vec4 bottomColor = texture(texture0, vec3(1.0, 0.11, 0.5));
24 vec4 expectedColor = mix(bottomColor, topColor, height);
26 vec4 dayColor = texture(texture0, fragmentTextureCoordinates);
28 float cloudFactor = reverseMix(length(dayColor.rg - expectedColor.rg), 0.15, length(vec2(1.0)));
30 outColor = vec4(dayColor.rgb, mix(cloudFactor, strengthen(cloudFactor, 8.0, 0.1), daylight));