Debian Codegraph @

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

raw
1 // from https://www.shadertoy.com/view/MlsGD7
2
3 // this shader was written from scratch by digorydoo, 2015.
4
5 float plasma (vec2 p, float t)
6 {
7 return clamp (sin (p.x*1.9 + cos (p.y*4.2 + t))
8 + cos (p.y*1.9 - sin (p.x*4.2 + t))
9 + 0.3, 0.0, 1.0);
10 }
11
12 void mainImage( out vec4 fragColor, in vec2 fragCoord )
13 {
14 vec2 uv = 2.0*(fragCoord.xy / iResolution.xy) - vec2 (0.5, 0.5);
15 uv.x *= iResolution.x / iResolution.y;
16 float t = iTime;
17
18 float grey = plasma (uv, t);
19 float prox = 1.0;
20 float alpha = 1.0;
21
22 for (int i = 0; i < 5; i++)
23 {
24 if (grey < 0.5) { alpha *= 0.5; prox *= 0.8; }
25 uv = uv*1.7 + vec2 (sin (t), 0.0);
26 t *= 0.7;
27 grey = mix (grey, grey*plasma (uv, t), alpha);
28 }
29
30 fragColor = 2.0 * grey * mix (
31 vec4 (1.0, 1.0, 0.5, 1.0), vec4 (0.15, 0.25, 0.4, 1.0), prox);
32 }