diff --git a/www/shaders/fbm.glsl b/www/shaders/fbm.glsl index b35ba8f..dcb1f4d 100644 --- a/www/shaders/fbm.glsl +++ b/www/shaders/fbm.glsl @@ -5,9 +5,8 @@ precision mediump float; #endif -uniform vec2 u_resolution; -uniform vec2 u_mouse; -uniform float u_time; +uniform vec2 uResolution; +uniform float uTime; float random (in vec2 _st) { return fract(sin(dot(_st.xy, @@ -65,17 +64,17 @@ float fbm ( in vec2 _st) { #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 st = gl_FragCoord.xy/uResolution.xy*SCALE; + // st += st * abs(sin(uTime*0.1)*3.0); vec2 q = vec2( - fbm( st + 0.*u_time), + fbm( st + 0.*uTime), 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) + fbm( st + 1.0*q + vec2(1.7,9.2)+ 0.15*uTime ), + fbm( st + 1.0*q + vec2(8.3,2.8)+ 0.126*uTime) ); float f = fbm(st+r); diff --git a/www/shaders/optimised.glsl b/www/shaders/optimised.glsl index 9d08431..8fd8d1b 100644 --- a/www/shaders/optimised.glsl +++ b/www/shaders/optimised.glsl @@ -13,8 +13,8 @@ precision mediump float; # endif #endif -uniform float u_time; -uniform vec2 u_resolution; +uniform float uTime; +uniform vec2 uResolution; /* ==== Text Colouring ==== */ #define PHOSPHOR_COL vec4(196./255., 167./255., 231./255., 1.) @@ -49,9 +49,9 @@ 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 + if (uResolution.y < 320.) // attempt to get rid of aliasing on small resolution return smoothstep(1.0, 0.9, f); - else if (u_resolution.y < 720.) + else if (uResolution.y < 720.) return smoothstep(0.75, 0.5, f); else return smoothstep(1., 0., f); @@ -196,7 +196,7 @@ float vt220Font(vec2 p, float c) { // 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 + float wt = 5. * (uTime + 0.5*sin(uTime*1.4) + 0.2*sin(uTime*2.9)); // wobbly time vec2 uvGt = uvG + vec2(0., floor(wt)); float ll = rand(vec2(uvGt.y, - 1.)) * ROWCOLS.x; // line length @@ -275,7 +275,7 @@ float fbm( in vec2 _st) { // 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 uv = gl_FragCoord.xy / uResolution; vec2 st = uv * SCALE; // // uvNoise = ceil(uvNoise * ROWCOLS) / ROWCOLS; @@ -295,13 +295,13 @@ void main() { // gl_FragColor = vt220Font(uvT - uvG * FONT_SIZE, val) * PHOSPHOR_COL + BG_COL; vec2 q = vec2( - fbm( st + 0.*u_time), + fbm( st + 0.*uTime), 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) + fbm( st + 1.0*q + vec2(1.7,9.2)+ 0.15*uTime ), + fbm( st + 1.0*q + vec2(8.3,2.8)+ 0.126*uTime) ); float f = fbm(st+r); diff --git a/www/shaders/sample.glsl b/www/shaders/sample.glsl new file mode 100644 index 0000000..9b54b8f --- /dev/null +++ b/www/shaders/sample.glsl @@ -0,0 +1,23 @@ +precision mediump float; + +// uniform float uTime; +uniform vec2 uResolution; + +void main() { + vec2 uv = gl_FragCoord.xy / uResolution.xy; + // vec3 col = 0.5 + 0.5 * cos(uTime + uv.xyx + vec3(0, 2, 4)); + // gl_FragColor = vec4(col, 1.0); + // gl_FragColor = vec4(216., 43., 72., 255.) / 255.; + + + // float maxfc = max(gl_FragCoord.x, gl_FragCoord.y); + // gl_FragColor = vec4(gl_FragCoord.xy, maxfc, maxfc) / maxfc; + + float maxuv = max(uv.x, uv.y); + gl_FragColor = vec4(34., 43., 192.*maxuv, 255.) / 255.; + + + // vec3 col = 0.5 + 0.5*cos(uv.xyx+vec3(0,2,4)); + // gl_FragColor = vec4(col, 1.); +} + diff --git a/www/shaders/segfault.glsl b/www/shaders/segfault.glsl index adabb14..a96bb19 100644 --- a/www/shaders/segfault.glsl +++ b/www/shaders/segfault.glsl @@ -11,8 +11,8 @@ precision mediump float; #endif -uniform float u_time; -uniform vec2 u_resolution; +uniform float uTime; +uniform vec2 uResolution; /* ==== Text Colouring ==== */ #define PHOSPHOR_COL vec4(196./255., 167./255., 231./255., 1.) @@ -155,9 +155,9 @@ 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 + if (uResolution.y < 320.) // attempt to get rid of aliasing on small resolution return smoothstep(1.0, 0.9, f); - else if (u_resolution.y < 720.) + else if (uResolution.y < 720.) return smoothstep(0.75, 0.5, f); else return smoothstep(1., 0., f); @@ -305,7 +305,7 @@ float vt220Font(vec2 p, float c) { // https://www.shadertoy.com/view/MsdGWn // 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 + float wt = 5. * (uTime + 0.5*sin(uTime*1.4) + 0.2*sin(uTime*2.9)); // wobbly time vec2 uvGt = uvG + vec2(0., floor(wt)); float ll = rand(vec2(uvGt.y, - 1.)) * ROWCOLS.x; // line length @@ -351,21 +351,21 @@ float smokeNoise(vec3 v) { } void main() { - vec2 uv = vec2(gl_FragCoord.x, u_resolution.y - gl_FragCoord.y); - vec2 uvT = ROWCOLS * FONT_SIZE * uv / u_resolution.xy; - vec2 uvG = floor(ROWCOLS * uv / u_resolution.xy); - vec2 uvC = gl_FragCoord.xy / u_resolution.xy; + vec2 uv = vec2(gl_FragCoord.x, uResolution.y - gl_FragCoord.y); + vec2 uvT = ROWCOLS * FONT_SIZE * uv / uResolution.xy; + vec2 uvG = floor(ROWCOLS * uv / uResolution.xy); + vec2 uvC = gl_FragCoord.xy / uResolution.xy; - vec2 uvNoise = gl_FragCoord.xy / u_resolution.xy; + vec2 uvNoise = gl_FragCoord.xy / uResolution.xy; uvNoise = ceil(uvNoise * ROWCOLS) / ROWCOLS; float val; - if (u_time < 2.0) + if (uTime < 2.0) val = textLines(uvG); - else if (u_time < 2.3) - val = rand(uvG * u_time) * 17.; + else if (uTime < 2.3) + val = rand(uvG * uTime) * 17.; else { - float noise = smokeNoise(vec3(uvNoise * noiseScale, u_time * noiseTimeScale)); + float noise = smokeNoise(vec3(uvNoise * noiseScale, uTime * noiseTimeScale)); // Noise is fed through a sigmoid function, then quantised to integer range 0-17 val = (exp(noise) / 2.71828); // increase contrast (normalised 0.0 - 1.0) val = 1.0 / val; diff --git a/www/shaders/trivial.glsl b/www/shaders/trivial.glsl index 22464ae..9935c91 100644 --- a/www/shaders/trivial.glsl +++ b/www/shaders/trivial.glsl @@ -1,17 +1,17 @@ // is highp wasteful for this shader? #ifdef GL_FRAGMENT_PRECISION_HIGH - precision highp float; +precision highp float; #else - precision mediump float; +precision mediump float; #endif -uniform float u_time; -uniform vec2 u_resolution; +uniform float uTime; +uniform vec2 uResolution; void main() { - vec2 uv = gl_FragCoord.xy / u_resolution; + vec2 uv = gl_FragCoord.xy / uResolution; - vec3 col = 0.5 + 0.5 * cos(u_time + uv.xyx + vec3(0, 2, 4)); + vec3 col = 0.5 + 0.5 * cos(uTime + uv.xyx + vec3(0, 2, 4)); gl_FragColor = vec4(col,1.0); }