]> git.lizzy.rs Git - dragonblocks_alpha.git/blob - shaders/sky/clouds/fragment.glsl
You can now see other players
[dragonblocks_alpha.git] / shaders / sky / clouds / fragment.glsl
1 in vec3 fragmentTextureCoordinates;
2
3 out vec4 outColor;
4
5 uniform float daylight;
6 uniform samplerCube texture0;
7
8 float reverseMix(float value, float min, float max)
9 {
10         return clamp((value - min) / (max - min), 0.0, 1.0);
11 }
12
13 float strengthen(float value, float exponent, float max)
14 {
15         return min((1.0 - pow(1.0 - value, exponent)) / (1.0 - pow(1.0 - max, exponent)), 1.0);
16 }
17
18 void main()
19 {
20         float height = normalize(fragmentTextureCoordinates).y;
21
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);
25
26         vec4 dayColor = texture(texture0, fragmentTextureCoordinates);
27
28         float cloudFactor = reverseMix(length(dayColor.rg - expectedColor.rg), 0.15, length(vec2(1.0)));
29
30         outColor = vec4(dayColor.rgb, mix(cloudFactor, strengthen(cloudFactor, 8.0, 0.1), daylight));
31 }