add uResolution uniform2f
This commit is contained in:
parent
9681cc76fa
commit
6ffcfa692e
3 changed files with 15 additions and 9 deletions
|
|
@ -18,6 +18,12 @@ 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;
|
||||||
|
|
|
||||||
|
|
@ -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,7 +141,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ precision highp float;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uniform float uTime;
|
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.)
|
||||||
|
|
@ -150,9 +151,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 (iResolution.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);
|
return smoothstep(1.0, 0.9, f);
|
||||||
else if (iResolution.y < 720.)
|
else if (uResolution.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);
|
||||||
|
|
@ -357,12 +358,12 @@ float bloom(vec2 uv2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mainImage(out vec4 fragColor) {
|
void mainImage(out vec4 fragColor) {
|
||||||
vec2 uv = vec2(gl_FragCoord.x, iResolution.y - gl_FragCoord.y);
|
vec2 uv = vec2(gl_FragCoord.x, uResolution.y - gl_FragCoord.y);
|
||||||
vec2 uvT = ROWCOLS * FONT_SIZE * uv / iResolution.xy;
|
vec2 uvT = ROWCOLS * FONT_SIZE * uv / uResolution.xy;
|
||||||
vec2 uvG = floor(ROWCOLS * uv / iResolution.xy);
|
vec2 uvG = floor(ROWCOLS * uv / uResolution.xy);
|
||||||
vec2 uvC = gl_FragCoord/iResolution.xy;
|
vec2 uvC = gl_FragCoord/uResolution.xy;
|
||||||
|
|
||||||
vec2 uvNoise = gl_FragCoord.xy / iResolution.xy;
|
vec2 uvNoise = gl_FragCoord.xy / uResolution.xy;
|
||||||
uvNoise = ceil(uvNoise * ROWCOLS) / ROWCOLS;
|
uvNoise = ceil(uvNoise * ROWCOLS) / ROWCOLS;
|
||||||
|
|
||||||
float val;
|
float val;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue