From ffad884915df9ed6f50f02094e14d0aafa226022 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Sun, 1 Feb 2026 15:42:28 +1000 Subject: [PATCH] brownian motion experiments --- www/shaders/fbm.glsl | 97 ++++++++++ www/shaders/optimised.glsl | 323 ++++++++++++++++++++++++++++++++ www/shaders/segfault.glsl | 4 +- www/shaders/working.glsl | 368 +++++++++++++++++++++++++++++++++++++ 4 files changed, 790 insertions(+), 2 deletions(-) create mode 100644 www/shaders/fbm.glsl create mode 100644 www/shaders/optimised.glsl create mode 100644 www/shaders/working.glsl diff --git a/www/shaders/fbm.glsl b/www/shaders/fbm.glsl new file mode 100644 index 0000000..b35ba8f --- /dev/null +++ b/www/shaders/fbm.glsl @@ -0,0 +1,97 @@ +// Author @patriciogv - 2015 +// http://patriciogonzalezvivo.com + +#ifdef GL_ES +precision mediump float; +#endif + +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +float random (in vec2 _st) { + return fract(sin(dot(_st.xy, + vec2(12.9898,78.233)))* + 43758.5453123); +} + +// Based on Morgan McGuire @morgan3d +// https://www.shadertoy.com/view/4dS3Wd +float noise (in vec2 _st) { + vec2 i = floor(_st); + vec2 f = fract(_st); + + // Four corners in 2D of a tile + float a = random(i); + float b = random(i + vec2(1.0, 0.0)); + float c = random(i + vec2(0.0, 1.0)); + float d = random(i + vec2(1.0, 1.0)); + + vec2 u = f * f * (3.0 - 2.0 * f); + + return mix(a, b, u.x) + + (c - a)* u.y * (1.0 - u.x) + + (d - b) * u.x * u.y; +} + +#define NUM_OCTAVES 100 +// Brightness (0.0 - 1.0) +#define BRIGHTNESS 0.55 +#define LACUNARITY 2.0 +#define GAIN 0.5 +#define SHIFT 100.0 + +// VAR_THETA defines whether to compute +// sin/cos values at runtime or +#define VAR_THETA 0 +#define THETA 0.5 +#if (VAR_THETA == 1) +#endif + +float fbm ( in vec2 _st) { + float v = 0.0; + float a = BRIGHTNESS; + // Rotate to reduce axial bias + mat2 T = LACUNARITY * mat2(cos(THETA), sin(THETA), + -sin(THETA), cos(THETA)); + for (int i = 0; i < NUM_OCTAVES; ++i) { + _st = T * _st + SHIFT; + v += noise(_st) * a; + a *= GAIN; + } + return v; +} + +#define SCALE 3. + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution.xy*SCALE; + // st += st * abs(sin(u_time*0.1)*3.0); + + vec2 q = vec2( + fbm( st + 0.*u_time), + fbm( st + vec2(1.0)) + ); + + vec2 r = vec2( + fbm( st + 1.0*q + vec2(1.7,9.2)+ 0.15*u_time ), + fbm( st + 1.0*q + vec2(8.3,2.8)+ 0.126*u_time) + ); + + float f = fbm(st+r); + + vec3 color = mix(vec3(0.101961,0.619608,0.666667), + vec3(0.666667,0.666667,0.498039), + clamp((f*f)*4.0,0.0,1.0)); + + color = mix(color, + vec3(0,0,0.164706), + clamp(length(q),0.0,1.0)); + + color = mix(color, + vec3(0.666667,1,1), + clamp(length(r.x),0.0,1.0)); + + gl_FragColor = vec4((f*f*f+.6*f*f+.5*f)*color,1.); +} + diff --git a/www/shaders/optimised.glsl b/www/shaders/optimised.glsl new file mode 100644 index 0000000..9d08431 --- /dev/null +++ b/www/shaders/optimised.glsl @@ -0,0 +1,323 @@ +/* BTW: You can use ANY function as the noise/plasma function + * It just needs to return a float in the range 0.0 - 17.0 + * But shouldn't return 0.0 or 17.0 (they're exclusive bounds). + * View this shader on shadertoy: https://www.shadertoy.com/view/t3tSRj# + */ + +// is highp wasteful for this shader? +#ifdef GL_ES +# ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +# else +precision mediump float; +# endif +#endif + +uniform float u_time; +uniform vec2 u_resolution; + +/* ==== Text Colouring ==== */ +#define PHOSPHOR_COL vec4(196./255., 167./255., 231./255., 1.) +// #define BG_COL vec4(0.2, 0.0, 0.2, 0.5) +#define BG_COL vec4(14./255., 13./255., 20./255., 1.) +/* ======= Text Size ======= */ +#define FONT_SIZE vec2(10.,20.) +#define ROWCOLS vec2(80., 24.) + +// =================================================================== +// Library Functions +// +float rand (in vec2 _st) { + return fract(sin(dot(_st.xy, vec2(12.9898,78.233))) * 43758.5453123); +} + +float quantise(float val, float n) { + return clamp(floor(val * n), 0.0, n) / n; +} + +float roundSquare(vec2 p, vec2 b, float r) { + return length(max(abs(p)-b,0.0))-r; +} + + +// =================================================================== +// VT220 Font Rendering +// Author/Source : https://www.shadertoy.com/view/llSXDV +// +#define l(y,a,b) roundLine(p, vec2(float(a), float(y)), vec2(float(b), float(y))) +float roundLine(vec2 p, vec2 a, vec2 b) { + b -= a + vec2(1.0,0.); + p -= a; + float f = length(p-clamp(dot(p,b)/dot(b,b),0.0,1.0)*b); + if (u_resolution.y < 320.) // attempt to get rid of aliasing on small resolution + return smoothstep(1.0, 0.9, f); + else if (u_resolution.y < 720.) + return smoothstep(0.75, 0.5, f); + else + return smoothstep(1., 0., f); +} + +float vt220Font(vec2 p, float c) { + if (c < 1.) return 0.; + if (p.y > 16.) { + if (c > 2.) return 0.0; + if (c > 1.) return l(17,1,9); + } + if (p.y > 14.) { + if (c > 16.) return l(15,3,8); + if (c > 15.) return l(15,1,8); + if (c > 14.) return l(15,1,3)+ l(15,7,9); + if (c > 13.) return l(15,2,8); + if (c > 12.) return l(15,1,9); + if (c > 11.) return l(15,2,8); + if (c > 10.) return l(15,1,3)+ l(15,6,8); + if (c > 9.) return l(15,4,6); + if (c > 8.) return l(15,2,4)+ l(15,5,7); + if (c > 7.) return l(15,2,8); + if (c > 6.) return l(15,2,8); + if (c > 5.) return l(15,2,8); + if (c > 4.) return l(15,2,9); + if (c > 3.) return l(15,1,8); + if (c > 2.) return l(15,2,9); + } + if (p.y > 12.) { + if (c > 16.) return l(13,2,4)+ l(13,7,9); + if (c > 15.) return l(13,2,4)+ l(13,7,9); + if (c > 14.) return l(13,1,3)+ l(13,7,9); + if (c > 13.) return l(13,1,3)+ l(13,7,9); + if (c > 12.) return l(13,1,3); + if (c > 11.) return l(13,4,6); + if (c > 10.) return l(13,2,4)+ l(13,5,9); + if (c > 9.) return l(13,2,8); + if (c > 8.) return l(13,2,4)+ l(13,5,7); + if (c > 7.) return l(13,1,3)+ l(13,7,9); + if (c > 6.) return l(13,1,3)+ l(13,7,9); + if (c > 5.) return l(13,1,3)+ l(13,7,9); + if (c > 4.) return l(13,1,3)+ l(15,2,9); + if (c > 3.) return l(13,1,4)+ l(13,7,9); + if (c > 2.) return l(13,1,3)+ l(13,6,9); + } + if (p.y > 10.) { + if (c > 16.) return l(11,1,3); + if (c > 15.) return l(11,2,4)+ l(11,7,9); + if (c > 14.) return l(11,1,9); + if (c > 13.) return l(11,7,9); + if (c > 12.) return l(11,2,5); + if (c > 11.) return l(11,4,6); + if (c > 10.) return l(11,3,5)+ l(11,6,8); + if (c > 9.) return l(11,4,6)+ l(11,7,9); + if (c > 8.) return l(11,1,8); + if (c > 7.) return l(11,1,3)+ l(11,7,9); + if (c > 6.) return l(11,1,3)+ l(11,7,9); + if (c > 5.) return l(11,1,3)+ l(11,7,9); + if (c > 4.) return l(11,1,3); + if (c > 3.) return l(11,1,3)+ l(11,7,9); + if (c > 2.) return l(11,2,9); + } + if (p.y > 8.) { + if (c > 16.) return l(9,1,3); + if (c > 15.) return l(9,2,8); + if (c > 14.) return l(9,1,3)+ l(9,7,9); + if (c > 13.) return l(9,4,8); + if (c > 12.) return l(9,4,8); + if (c > 11.) return l(9,4,6); + if (c > 10.) return l(9,4,6); + if (c > 9.) return l(9,2,8); + if (c > 8.) return l(9,2,4)+ l(9,5,7); + if (c > 7.) return l(9,1,3)+ l(9,7,9); + if (c > 6.) return l(9,1,3)+ l(9,7,9); + if (c > 5.) return l(9,1,3)+ l(9,7,9); + if (c > 4.) return l(9,1,3)+ l(9,7,9); + if (c > 3.) return l(9,1,4)+ l(9,7,9); + if (c > 2.) return l(9,7,9); + } + if (p.y > 6.) { + if (c > 16.) return l(7,1,3); + if (c > 15.) return l(7,2,4)+ l(7,7,9); + if (c > 14.) return l(7,2,4)+ l(7,6,8); + if (c > 13.) return l(7,5,7); + if (c > 12.) return l(7,7,9); + if (c > 11.) return l(7,2,6); + if (c > 10.) return l(7,2,4)+ l(7,5,7); + if (c > 9.) return l(7,1,3)+ l(7,4,6); + if (c > 8.) return l(7,1,8); + if (c > 7.) return l(7,2,8); + if (c > 6.) return l(7,2,8); + if (c > 5.) return l(7,2,8); + if (c > 4.) return l(7,2,8); + if (c > 3.) return l(7,1,8); + if (c > 2.) return l(7,2,8); + } + if (p.y > 4.) { + if (c > 16.) return l(5,2,4)+ l(5,7,9); + if (c > 15.) return l(5,2,4)+ l(5,7,9); + if (c > 14.) return l(5,3,7); + if (c > 13.) return l(5,6,8); + if (c > 12.) return l(5,1,3)+ l(5,7,9); + if (c > 11.) return l(5,3,6); + if (c > 10.) return l(5,1,5)+ l(5,6,8); + if (c > 9.) return l(5,2,8); + if (c > 8.) return l(5,2,4)+ l(5,5,7); + if (c > 7.) return 0.; + if (c > 6.) return 0.; + if (c > 5.) return 0.; + if (c > 4.) return 0.; + if (c > 3.) return l(5,1,3); + if (c > 2.) return 0.; + } + if (p.y > 2.) { + if (c > 16.) return l(3,3,8); + if (c > 15.) return l(3,1,8); + if (c > 14.) return l(3,4,6); + if (c > 13.) return l(3,1,9); + if (c > 12.) return l(3,2,8); + if (c > 11.) return l(3,4,6); + if (c > 10.) return l(3,2,4)+ l(3,7,9); + if (c > 9.) return l(3,4,6); + if (c > 8.) return l(3,2,4)+ l(3,5,7); + if (c > 7.) return l(3,2,4)+ l(3,6,8); + if (c > 6.) return l(3,1,3)+ l(3,4,7); + if (c > 5.) return l(3,2,4)+ l(3,6,8); + if (c > 4.) return 0.; + if (c > 3.) return l(3,1,3); + if (c > 2.) return 0.; + } + else { + if (c > 7.) return 0.; + if (c > 6.) return l(1,2,5)+ l(1,6,8); + } + return 0.0; +} + + +// =================================================================== +// Text Effects +// textLines(...) is for simulating the writing of random characters in line formats +// https://www.shadertoy.com/view/llSXDV (same author as VT220 font rendering) +// +float textLines(vec2 uvG) { + float wt = 5. * (u_time + 0.5*sin(u_time*1.4) + 0.2*sin(u_time*2.9)); // wobbly time + vec2 uvGt = uvG + vec2(0., floor(wt)); + float ll = rand(vec2(uvGt.y, - 1.)) * ROWCOLS.x; // line length + + if (uvG.y > ROWCOLS.y - 2.){ + if (ceil(uvG.x) == floor(min(ll, fract(wt)*ROWCOLS.x))) + return 2.; + if (ceil(uvG.x) > floor(min(ll, fract(wt)*ROWCOLS.x))) + return 0.; + } + if (uvGt.x > 5. && rand(uvGt) < .075) + return 0.; + if (max(5., uvGt.x) > ll) + return 0.; + + return rand(uvGt)*15. + 2.; +} + + +// =================================================================== +// Noise Generation Algorithms +// noise(...) is for the main noise generation algorithm (very tunable) +// https://www.shadertoy.com/view/MsdGWn +// + +// Based on Morgan McGuire @morgan3d +// https://www.shadertoy.com/view/4dS3Wd +float noise (in vec2 _st) { + vec2 i = floor(_st); + vec2 f = fract(_st); + + // Four corners in 2D of a tile + float a = rand(i); + float b = rand(i + vec2(1.0, 0.0)); + float c = rand(i + vec2(0.0, 1.0)); + float d = rand(i + vec2(1.0, 1.0)); + + vec2 u = f * f * (3.0 - 2.0 * f); + + return mix(a, b, u.x) + + (c - a)* u.y * (1.0 - u.x) + + (d - b) * u.x * u.y; +} + +#define NUM_OCTAVES 100 +// Brightness (0.0 - 1.0) +#define BRIGHTNESS 0.55 +#define LACUNARITY 2.0 +#define GAIN 0.5 +#define SHIFT 100.0 + +// VAR_THETA defines whether to compute +// sin/cos values at runtime or +#define VAR_THETA 0 +#define THETA 0.5 +#if (VAR_THETA == 1) +#endif + +float fbm( in vec2 _st) { + float v = 0.0; + float a = BRIGHTNESS; + // Rotate to reduce axial bias + mat2 T = LACUNARITY * mat2(cos(THETA), sin(THETA), + -sin(THETA), cos(THETA)); + for (int i = 0; i < NUM_OCTAVES; ++i) { + _st = T * _st + SHIFT; + v += noise(_st) * a; + a *= GAIN; + } + return v; +} + + +#define SCALE_UV 3. +#define SCALE_TIME 1. + +// XXX: TODO: use two shaders, the first on a MUCH lower resolution (one pixel for each text character) +// XXX: TODO: then the second should map those pixel values to higher resolution text characters +void main() { + vec2 uv = gl_FragCoord.xy / u_resolution; + vec2 st = uv * SCALE; + + // // uvNoise = ceil(uvNoise * ROWCOLS) / ROWCOLS; + // float val = noise(st); + // // Noise is fed through a sigmoid function, then quantised to integer range 0-17 + // val = (exp(val) / 2.71828); // increase contrast (normalised 0.0 - 1.0) + // val = 1.0 / val; + // val *= 1.0 / (1.0 + exp(-val)) - 0.5; // subtraction value is tunable (range 0.0 - 0.5) + // val *= quantise(val, 17.0); // quantise by 17 then normalise back to 0.0 - 1.0 + // val = pow(18.0, val) - 1.0; // TODO: try changing 18.0 to 200.0 and you'll notice some pretty changes :) + + // // VT220 Font Rendering + // vec2 base = uv; + // base.y = 1 - base.y; + // vec2 uvT = ROWCOLS * FONT_SIZE * base; + // vec2 uvG = floor(ROWCOLS * base; + // gl_FragColor = vt220Font(uvT - uvG * FONT_SIZE, val) * PHOSPHOR_COL + BG_COL; + + vec2 q = vec2( + fbm( st + 0.*u_time), + fbm( st + vec2(1.0)) + ); + + vec2 r = vec2( + fbm( st + 1.0*q + vec2(1.7,9.2)+ 0.15*u_time ), + fbm( st + 1.0*q + vec2(8.3,2.8)+ 0.126*u_time) + ); + + float f = fbm(st+r); + + vec3 color = mix(vec3(0.101961,0.619608,0.666667), + vec3(0.666667,0.666667,0.498039), + clamp((f*f)*4.0,0.0,1.0)); + + color = mix(color, + vec3(0,0,0.164706), + clamp(length(q),0.0,1.0)); + + color = mix(color, + vec3(0.666667,1,1), + clamp(length(r.x),0.0,1.0)); + + gl_FragColor = vec4((f*f*f+.6*f*f+.5*f)*color,1.); +} + diff --git a/www/shaders/segfault.glsl b/www/shaders/segfault.glsl index a3d73a8..adabb14 100644 --- a/www/shaders/segfault.glsl +++ b/www/shaders/segfault.glsl @@ -15,9 +15,9 @@ uniform float u_time; uniform vec2 u_resolution; /* ==== Text Colouring ==== */ -#define PHOSPHOR_COL vec4(1, 1., 1., 1.) +#define PHOSPHOR_COL vec4(196./255., 167./255., 231./255., 1.) // #define BG_COL vec4(0.2, 0.0, 0.2, 0.5) -#define BG_COL vec4(0.0, 0.0, 0.0, 1.) +#define BG_COL vec4(14./255., 13./255., 20./255., 1.) /* ======= Text Size ======= */ #define FONT_SIZE vec2(10.,20.) #define ROWCOLS vec2(80., 24.) diff --git a/www/shaders/working.glsl b/www/shaders/working.glsl new file mode 100644 index 0000000..71a0872 --- /dev/null +++ b/www/shaders/working.glsl @@ -0,0 +1,368 @@ +// WARNING: NOTE: this works on https://glslsandbox.com/e +precision highp float; + +uniform float time; +uniform vec2 resolution; + +/* ==== Text Colouring ==== */ +#define PHOSPHOR_COL vec4(1, 1., 1., 1.) +#define BG_COL vec4(0.2, 0.0, 0.2, 0.) +/* ======= Text Size ======= */ +#define FONT_SIZE vec2(10.,20.) +#define ROWCOLS vec2(80., 24.) +/* === Text Bloom Effect === */ +#define WIDTH 1.2 +#define HEIGHT 0.7 +#define SMOOTH 0.004 +/* ====== Smoke Noise ====== */ +const int noiseSwirlSteps = 0; +const float noiseSwirlValue = 1.; +const float noiseSwirlStepValue = noiseSwirlValue / float(noiseSwirlSteps); +const float noiseScale = 1.0; +const float noiseTimeScale = 0.1; + +// =================================================================== +// Library Functions +// +float rand(vec2 co) { + return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); +} + +float quantise(float val, float n) { + return clamp(floor(val * n), 0.0, n) / n; +} + +float roundSquare(vec2 p, vec2 b, float r) { + return length(max(abs(p)-b,0.0))-r; +} + +// standard roundSquare +float stdRS(vec2 uv, float r) { + return roundSquare(uv - 0.5, vec2(WIDTH, HEIGHT) + r, 0.05); +} + +// =================================================================== +// Description : Array and textureless GLSL 2D/3D/4D simplex +// noise functions. +// Author : Ian McEwan, Ashima Arts. +// Maintainer : ijm +// Lastmod : 20110822 (ijm) +// License : Copyright (C) 2011 Ashima Arts. All rights reserved. +// Distributed under the MIT License. See LICENSE file. +// https://github.com/ashima/webgl-noise +// +vec3 mod289(vec3 x) { + return x - floor(x * (1.0 / 289.0)) * 289.0; +} + +vec4 mod289(vec4 x) { + return x - floor(x * (1.0 / 289.0)) * 289.0; +} + +vec4 permute(vec4 x) { + return mod289(((x*34.0)+1.0)*x); +} + +vec4 taylorInvSqrt(vec4 r) { + return 1.79284291400159 - 0.85373472095314 * r; +} + +float simplex(vec3 v) { + const vec2 C = vec2(1.0/6.0, 1.0/3.0) ; + const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); + + // First corner + vec3 i = floor(v + dot(v, C.yyy) ); + vec3 x0 = v - i + dot(i, C.xxx) ; + + // Other corners + vec3 g = step(x0.yzx, x0.xyz); + vec3 l = 1.0 - g; + vec3 i1 = min( g.xyz, l.zxy ); + vec3 i2 = max( g.xyz, l.zxy ); + + vec3 x1 = x0 - i1 + C.xxx; + vec3 x2 = x0 - i2 + C.yyy; + vec3 x3 = x0 - D.yyy; + + // Permutations + i = mod289(i); + vec4 p = permute( permute( permute( + i.z + vec4(0.0, i1.z, i2.z, 1.0 )) + + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) + + i.x + vec4(0.0, i1.x, i2.x, 1.0 )); + + // Gradients: 7x7 points over a square, mapped onto an octahedron. + // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) + float n_ = 0.142857142857; // 1.0/7.0 + vec3 ns = n_ * D.wyz - D.xzx; + + vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7) + + vec4 x_ = floor(j * ns.z); + vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N) + + vec4 x = x_ *ns.x + ns.yyyy; + vec4 y = y_ *ns.x + ns.yyyy; + vec4 h = 1.0 - abs(x) - abs(y); + + vec4 b0 = vec4( x.xy, y.xy ); + vec4 b1 = vec4( x.zw, y.zw ); + + vec4 s0 = floor(b0)*2.0 + 1.0; + vec4 s1 = floor(b1)*2.0 + 1.0; + vec4 sh = -step(h, vec4(0.0)); + + vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ; + vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ; + + vec3 p0 = vec3(a0.xy,h.x); + vec3 p1 = vec3(a0.zw,h.y); + vec3 p2 = vec3(a1.xy,h.z); + vec3 p3 = vec3(a1.zw,h.w); + + //Normalise gradients + vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); + p0 *= norm.x; + p1 *= norm.y; + p2 *= norm.z; + p3 *= norm.w; + + // Mix final noise value + vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0); + m = m * m; + return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3,x3) ) ); +} + + +// =================================================================== +// VT220 Font Rendering +// Author/Source : https://www.shadertoy.com/view/llSXDV +// +#define l(y,a,b) roundLine(p, vec2(float(a), float(y)), vec2(float(b), float(y))) +float roundLine(vec2 p, vec2 a, vec2 b) { + b -= a + vec2(1.0,0.); + p -= a; + float f = length(p-clamp(dot(p,b)/dot(b,b),0.0,1.0)*b); + if (resolution.y < 320.) // attempt to get rid of aliasing on small resolution + return smoothstep(1.0, 0.9, f); + else if (resolution.y < 720.) + return smoothstep(0.75, 0.5, f); + else + return smoothstep(1., 0., f); +} + +float vt220Font(vec2 p, float c) { + if (c < 1.) return 0.; + if (p.y > 16.) { + if (c > 2.) return 0.0; + if (c > 1.) return l(17,1,9); + } + if (p.y > 14.) { + if (c > 16.) return l(15,3,8); + if (c > 15.) return l(15,1,8); + if (c > 14.) return l(15,1,3)+ l(15,7,9); + if (c > 13.) return l(15,2,8); + if (c > 12.) return l(15,1,9); + if (c > 11.) return l(15,2,8); + if (c > 10.) return l(15,1,3)+ l(15,6,8); + if (c > 9.) return l(15,4,6); + if (c > 8.) return l(15,2,4)+ l(15,5,7); + if (c > 7.) return l(15,2,8); + if (c > 6.) return l(15,2,8); + if (c > 5.) return l(15,2,8); + if (c > 4.) return l(15,2,9); + if (c > 3.) return l(15,1,8); + if (c > 2.) return l(15,2,9); + } + if (p.y > 12.) { + if (c > 16.) return l(13,2,4)+ l(13,7,9); + if (c > 15.) return l(13,2,4)+ l(13,7,9); + if (c > 14.) return l(13,1,3)+ l(13,7,9); + if (c > 13.) return l(13,1,3)+ l(13,7,9); + if (c > 12.) return l(13,1,3); + if (c > 11.) return l(13,4,6); + if (c > 10.) return l(13,2,4)+ l(13,5,9); + if (c > 9.) return l(13,2,8); + if (c > 8.) return l(13,2,4)+ l(13,5,7); + if (c > 7.) return l(13,1,3)+ l(13,7,9); + if (c > 6.) return l(13,1,3)+ l(13,7,9); + if (c > 5.) return l(13,1,3)+ l(13,7,9); + if (c > 4.) return l(13,1,3)+ l(15,2,9); + if (c > 3.) return l(13,1,4)+ l(13,7,9); + if (c > 2.) return l(13,1,3)+ l(13,6,9); + } + if (p.y > 10.) { + if (c > 16.) return l(11,1,3); + if (c > 15.) return l(11,2,4)+ l(11,7,9); + if (c > 14.) return l(11,1,9); + if (c > 13.) return l(11,7,9); + if (c > 12.) return l(11,2,5); + if (c > 11.) return l(11,4,6); + if (c > 10.) return l(11,3,5)+ l(11,6,8); + if (c > 9.) return l(11,4,6)+ l(11,7,9); + if (c > 8.) return l(11,1,8); + if (c > 7.) return l(11,1,3)+ l(11,7,9); + if (c > 6.) return l(11,1,3)+ l(11,7,9); + if (c > 5.) return l(11,1,3)+ l(11,7,9); + if (c > 4.) return l(11,1,3); + if (c > 3.) return l(11,1,3)+ l(11,7,9); + if (c > 2.) return l(11,2,9); + } + if (p.y > 8.) { + if (c > 16.) return l(9,1,3); + if (c > 15.) return l(9,2,8); + if (c > 14.) return l(9,1,3)+ l(9,7,9); + if (c > 13.) return l(9,4,8); + if (c > 12.) return l(9,4,8); + if (c > 11.) return l(9,4,6); + if (c > 10.) return l(9,4,6); + if (c > 9.) return l(9,2,8); + if (c > 8.) return l(9,2,4)+ l(9,5,7); + if (c > 7.) return l(9,1,3)+ l(9,7,9); + if (c > 6.) return l(9,1,3)+ l(9,7,9); + if (c > 5.) return l(9,1,3)+ l(9,7,9); + if (c > 4.) return l(9,1,3)+ l(9,7,9); + if (c > 3.) return l(9,1,4)+ l(9,7,9); + if (c > 2.) return l(9,7,9); + } + if (p.y > 6.) { + if (c > 16.) return l(7,1,3); + if (c > 15.) return l(7,2,4)+ l(7,7,9); + if (c > 14.) return l(7,2,4)+ l(7,6,8); + if (c > 13.) return l(7,5,7); + if (c > 12.) return l(7,7,9); + if (c > 11.) return l(7,2,6); + if (c > 10.) return l(7,2,4)+ l(7,5,7); + if (c > 9.) return l(7,1,3)+ l(7,4,6); + if (c > 8.) return l(7,1,8); + if (c > 7.) return l(7,2,8); + if (c > 6.) return l(7,2,8); + if (c > 5.) return l(7,2,8); + if (c > 4.) return l(7,2,8); + if (c > 3.) return l(7,1,8); + if (c > 2.) return l(7,2,8); + } + if (p.y > 4.) { + if (c > 16.) return l(5,2,4)+ l(5,7,9); + if (c > 15.) return l(5,2,4)+ l(5,7,9); + if (c > 14.) return l(5,3,7); + if (c > 13.) return l(5,6,8); + if (c > 12.) return l(5,1,3)+ l(5,7,9); + if (c > 11.) return l(5,3,6); + if (c > 10.) return l(5,1,5)+ l(5,6,8); + if (c > 9.) return l(5,2,8); + if (c > 8.) return l(5,2,4)+ l(5,5,7); + if (c > 7.) return 0.; + if (c > 6.) return 0.; + if (c > 5.) return 0.; + if (c > 4.) return 0.; + if (c > 3.) return l(5,1,3); + if (c > 2.) return 0.; + } + if (p.y > 2.) { + if (c > 16.) return l(3,3,8); + if (c > 15.) return l(3,1,8); + if (c > 14.) return l(3,4,6); + if (c > 13.) return l(3,1,9); + if (c > 12.) return l(3,2,8); + if (c > 11.) return l(3,4,6); + if (c > 10.) return l(3,2,4)+ l(3,7,9); + if (c > 9.) return l(3,4,6); + if (c > 8.) return l(3,2,4)+ l(3,5,7); + if (c > 7.) return l(3,2,4)+ l(3,6,8); + if (c > 6.) return l(3,1,3)+ l(3,4,7); + if (c > 5.) return l(3,2,4)+ l(3,6,8); + if (c > 4.) return 0.; + if (c > 3.) return l(3,1,3); + if (c > 2.) return 0.; + } + else { + if (c > 7.) return 0.; + if (c > 6.) return l(1,2,5)+ l(1,6,8); + } + return 0.0; +} + + +// =================================================================== +// Noise Generation Algorithms +// textLines(...) is for simulating the writing of random characters in line formats +// https://www.shadertoy.com/view/llSXDV (same author as VT220 font rendering) +// +// smokeNoise(...) is for the main noise generation algorithm (very tunable) +// https://www.shadertoy.com/view/MsdGWn +// +float textLines(vec2 uvG) { + float wt = 5. * (time + 0.5*sin(time*1.4) + 0.2*sin(time*2.9)); // wobbly time + vec2 uvGt = uvG + vec2(0., floor(wt)); + float ll = rand(vec2(uvGt.y, - 1.)) * ROWCOLS.x; // line length + + if (uvG.y > ROWCOLS.y - 2.){ + if (ceil(uvG.x) == floor(min(ll, fract(wt)*ROWCOLS.x))) + return 2.; + if (ceil(uvG.x) > floor(min(ll, fract(wt)*ROWCOLS.x))) + return 0.; + } + if (uvGt.x > 5. && rand(uvGt) < .075) + return 0.; + if (max(5., uvGt.x) > ll) + return 0.; + + return rand(uvGt)*15. + 2.; +} + +float fbm3(vec3 v) { + float result = simplex(v); + result += simplex(v * 2.) / 2.; + result += simplex(v * 4.) / 4.; + result /= (1. + 1./2. + 1./4.); + return result; +} + +float fbm5(vec3 v) { + float result = simplex(v); + result += simplex(v * 2.) / 2.; + result += simplex(v * 4.) / 4.; + result += simplex(v * 8.) / 8.; + result += simplex(v * 16.) / 16.; + result /= (1. + 1./2. + 1./4. + 1./8. + 1./16.); + return result; +} + +float smokeNoise(vec3 v) { + // make it curl + for (int i=0; i