Debian Codegraph @

screensaver.shadertoy/resources/shaders/bluefire.frag.glsl

raw
1 // Taken from https://www.shadertoy.com/view/4dlGR2
2
3 // by @301z
4 // noise 3D by by inigo quilez
5
6 float noise( in vec2 xx )
7 {
8 vec3 x = vec3(xx,0.0);
9 vec3 p = floor(x);
10 vec3 f = fract(x);
11 f = f*f*(3.0-2.0*f);
12
13 vec2 uv = (p.xy+vec2(37.0,17.0)*p.z) + f.xy;
14 vec2 rg = texture( iChannel0, (uv+0.5)/256.0, -100.0 ).yx;
15 return mix( rg.x, rg.y, f.z );
16 }
17
18 float fbm(vec2 n) {
19 float total = 0.0, amplitude = 1.0;
20 for (int i = 0; i < 7; i++) {
21 total += noise(n) * amplitude;
22 n += n;
23 amplitude *= 0.5;
24 }
25 return total;
26 }
27
28 void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
29 const vec3 c1 = vec3(0.1, 0.0, 0.0);
30 const vec3 c2 = vec3(0.7, 0.0, 0.0);
31 const vec3 c3 = vec3(0.2, 0.0, 0.0);
32 const vec3 c4 = vec3(1.0, 0.9, 0.0);
33 const vec3 c5 = vec3(0.1);
34 const vec3 c6 = vec3(0.9);
35 vec2 p = fragCoord.xy * 8.0 / iResolution.xx;
36 float q = fbm(p - iTime * 0.1);
37 vec2 r = vec2(fbm(p + q + iTime * 0.7 - p.x - p.y), fbm(p + q - iTime * 0.4));
38 vec3 c = mix(c1, c2, fbm(p + r)) + mix(c3, c4, r.x) - mix(c5, c6, r.y);
39 fragColor = vec4(c * -cos(1.57 * fragCoord.y / iResolution.y), 1.0);
40 }