Compare commits

..

No commits in common. "6ffcfa692ec1ca75fd356a799be61a14ed0ccd96" and "c4569168c7ee63ff915c900270584ccc36babf7f" have entirely different histories.

3 changed files with 17 additions and 27 deletions

View file

@ -18,12 +18,6 @@ function drawScene(gl, programInfo, buffers, time) {
programInfo.uniformLocations.time, programInfo.uniformLocations.time,
time, time,
); );
// Viewport resolution in pixels
gl.uniform2f(
programInfo.uniformLocations.resolution,
gl.drawingBufferWidth,
gl.drawingBufferHeight,
);
{ {
const offset = 0; const offset = 0;

View file

@ -121,7 +121,7 @@ function main() {
vertexPosition: gl.getAttribLocation(shaderProgram, "aVertexPosition"), vertexPosition: gl.getAttribLocation(shaderProgram, "aVertexPosition"),
}, },
uniformLocations: { uniformLocations: {
resolution: context.getUniformLocation(program, "uResolution"), // resolution: context.getUniformLocation(program, "uResolution"),
time: gl.getUniformLocation(shaderProgram, "uTime"), time: gl.getUniformLocation(shaderProgram, "uTime"),
}, },
}; };
@ -141,6 +141,7 @@ function main() {
// deltaTime = time - prevTime; // deltaTime = time - prevTime;
// prevTime = time; // prevTime = time;
console.log(time)
drawScene(gl, programInfo, buffers, time); drawScene(gl, programInfo, buffers, time);
requestAnimationFrame(render); requestAnimationFrame(render);
} }

View file

@ -4,12 +4,7 @@
* View this shader on shadertoy: https://www.shadertoy.com/view/t3tSRj# * View this shader on shadertoy: https://www.shadertoy.com/view/t3tSRj#
*/ */
#ifdef GL_ES
precision highp float; precision highp float;
#endif
uniform float uTime;
uniform vec2 uResolution;
/* ==== Text Colouring ==== */ /* ==== Text Colouring ==== */
#define PHOSPHOR_COL vec4(1, 1., 1., 1.) #define PHOSPHOR_COL vec4(1, 1., 1., 1.)
@ -151,9 +146,9 @@ float roundLine(vec2 p, vec2 a, vec2 b) {
b -= a + vec2(1.0,0.); b -= a + vec2(1.0,0.);
p -= a; p -= a;
float f = length(p-clamp(dot(p,b)/dot(b,b),0.0,1.0)*b); float f = length(p-clamp(dot(p,b)/dot(b,b),0.0,1.0)*b);
if (uResolution.y < 320.) // attempt to get rid of aliasing on small resolution if (iResolution.y < 320.) // attempt to get rid of aliasing on small resolution
return smoothstep(1.0, 0.9, f); return smoothstep(1.0, 0.9, f);
else if (uResolution.y < 720.) else if (iResolution.y < 720.)
return smoothstep(0.75, 0.5, f); return smoothstep(0.75, 0.5, f);
else else
return smoothstep(1., 0., f); return smoothstep(1., 0., f);
@ -301,7 +296,7 @@ float vt220Font(vec2 p, float c) {
// https://www.shadertoy.com/view/MsdGWn // https://www.shadertoy.com/view/MsdGWn
// //
float textLines(vec2 uvG) { float textLines(vec2 uvG) {
float wt = 5. * (uTime + 0.5*sin(uTime*1.4) + 0.2*sin(uTime*2.9)); // wobbly time float wt = 5. * (iTime + 0.5*sin(iTime*1.4) + 0.2*sin(iTime*2.9)); // wobbly time
vec2 uvGt = uvG + vec2(0., floor(wt)); vec2 uvGt = uvG + vec2(0., floor(wt));
float ll = rand(vec2(uvGt.y, - 1.)) * ROWCOLS.x; // line length float ll = rand(vec2(uvGt.y, - 1.)) * ROWCOLS.x; // line length
@ -357,22 +352,22 @@ float bloom(vec2 uv2) {
* smoothstep(0., -SMOOTH*20., stdRS(uvC, -0.02)) * 0.5; * smoothstep(0., -SMOOTH*20., stdRS(uvC, -0.02)) * 0.5;
} }
void mainImage(out vec4 fragColor) { void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = vec2(gl_FragCoord.x, uResolution.y - gl_FragCoord.y); vec2 uv = vec2(fragCoord.x, iResolution.y - fragCoord.y);
vec2 uvT = ROWCOLS * FONT_SIZE * uv / uResolution.xy; vec2 uvT = ROWCOLS * FONT_SIZE * uv / iResolution.xy;
vec2 uvG = floor(ROWCOLS * uv / uResolution.xy); vec2 uvG = floor(ROWCOLS * uv / iResolution.xy);
vec2 uvC = gl_FragCoord/uResolution.xy; vec2 uvC = fragCoord/iResolution.xy;
vec2 uvNoise = gl_FragCoord.xy / uResolution.xy; vec2 uvNoise = fragCoord.xy / iResolution.xy;
uvNoise = ceil(uvNoise * ROWCOLS) / ROWCOLS; uvNoise = ceil(uvNoise * ROWCOLS) / ROWCOLS;
float val; float val;
if (uTime < 2.0) if (iTime < 2.0)
val = textLines(uvG); val = textLines(uvG);
else if (uTime < 2.3) else if (iTime < 2.3)
val = rand(uvG * uTime) * 17.; val = rand(uvG * iTime) * 17.;
else { else {
float noise = smokeNoise(vec3(uvNoise * noiseScale, uTime * noiseTimeScale)); float noise = smokeNoise(vec3(uvNoise * noiseScale, iTime * noiseTimeScale));
// Noise is fed through a sigmoid function, then quantised to integer range 0-17 // 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 = (exp(noise) / 2.71828); // increase contrast (normalised 0.0 - 1.0)
val = 1.0 / val; val = 1.0 / val;