From c0d19f102ab0e09532ca2aec294c335491dad206 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Sat, 31 Jan 2026 11:32:09 +1000 Subject: [PATCH] fix uTime uniform --- www/js/draw-scene.js | 4 ++-- www/shaders/segfault.glsl | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/www/js/draw-scene.js b/www/js/draw-scene.js index f407c6d..d325b87 100644 --- a/www/js/draw-scene.js +++ b/www/js/draw-scene.js @@ -5,7 +5,7 @@ function drawScene(gl, programInfo, buffers, time) { // NOTE: this is how width/height is taken // const aspect = gl.canvas.clientWidth / gl.canvas.clientHeight; - + // Tell WebGL how to pull out the positions from the position // buffer into the vertexPosition attribute. setPositionAttribute(gl, buffers, programInfo); @@ -17,7 +17,7 @@ function drawScene(gl, programInfo, buffers, time) { gl.uniform1f( programInfo.uniformLocations.time, time, - ); + ); { const offset = 0; diff --git a/www/shaders/segfault.glsl b/www/shaders/segfault.glsl index 9448d14..cd0474d 100644 --- a/www/shaders/segfault.glsl +++ b/www/shaders/segfault.glsl @@ -4,8 +4,11 @@ * View this shader on shadertoy: https://www.shadertoy.com/view/t3tSRj# */ +#ifdef GL_ES precision highp float; +#endif +uniform float uTime; /* ==== Text Colouring ==== */ #define PHOSPHOR_COL vec4(1, 1., 1., 1.) #define BG_COL vec4(0.2, 0.0, 0.2, 0.) @@ -296,7 +299,7 @@ float vt220Font(vec2 p, float c) { // https://www.shadertoy.com/view/MsdGWn // float textLines(vec2 uvG) { - float wt = 5. * (iTime + 0.5*sin(iTime*1.4) + 0.2*sin(iTime*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 @@ -362,12 +365,12 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) { uvNoise = ceil(uvNoise * ROWCOLS) / ROWCOLS; float val; - if (iTime < 2.0) + if (uTime < 2.0) val = textLines(uvG); - else if (iTime < 2.3) - val = rand(uvG * iTime) * 17.; + else if (uTime < 2.3) + val = rand(uvG * uTime) * 17.; else { - float noise = smokeNoise(vec3(uvNoise * noiseScale, iTime * 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;