1 float pnoise(vec2 P, vec2 rep);
2 float pnoise_octaves();
6 float alt = min((gl_TexCoord[0].y + 0.29)* 2.0, 1.0);
7 float cloud_dens = 0.5;
9 //const vec3 col_hor = vec3(0.96, 0.55, 0.98);
10 const vec3 col_hor = vec3(0.95, 0.38, 0.54);
11 const vec3 col_zen = vec3(0.05, 0.15, 0.32);
13 gl_FragColor.rgb = mix(col_hor, col_zen, alt);
19 // GLSL textureless classic 2D noise "cnoise",
20 // with an RSL-style periodic variant "pnoise".
21 // Author: Stefan Gustavson (stefan.gustavson@liu.se)
22 // Version: 2011-08-22
24 // Many thanks to Ian McEwan of Ashima Arts for the
25 // ideas for permutation and gradient selection.
27 // Copyright (c) 2011 Stefan Gustavson. All rights reserved.
28 // Distributed under the MIT license. See LICENSE file.
29 // https://github.com/ashima/webgl-noise
34 return x - floor(x * (1.0 / 289.0)) * 289.0;
39 return mod289(((x*34.0)+1.0)*x);
42 vec4 taylorInvSqrt(vec4 r)
44 return 1.79284291400159 - 0.85373472095314 * r;
48 return t*t*t*(t*(t*6.0-15.0)+10.0);
51 // Classic Perlin noise, periodic variant
52 float pnoise(vec2 P, vec2 rep)
54 vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);
55 vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);
56 Pi = mod(Pi, rep.xyxy); // To create noise with explicit period
57 Pi = mod289(Pi); // To avoid truncation effects in permutation
63 vec4 i = permute(permute(ix) + iy);
65 vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ;
66 vec4 gy = abs(gx) - 0.5 ;
67 vec4 tx = floor(gx + 0.5);
70 vec2 g00 = vec2(gx.x,gy.x);
71 vec2 g10 = vec2(gx.y,gy.y);
72 vec2 g01 = vec2(gx.z,gy.z);
73 vec2 g11 = vec2(gx.w,gy.w);
75 vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
81 float n00 = dot(g00, vec2(fx.x, fy.x));
82 float n10 = dot(g10, vec2(fx.y, fy.y));
83 float n01 = dot(g01, vec2(fx.z, fy.z));
84 float n11 = dot(g11, vec2(fx.w, fy.w));
86 vec2 fade_xy = fade(Pf.xy);
87 vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);
88 float n_xy = mix(n_x.x, n_x.y, fade_xy.y);
92 #pragma glslify: export(pnoise)