kopia lustrzana https://github.com/m1el/woscope
make foreground color configurable
- fsLine.glsl: remove redundant "precision highp float;"pull/6/head
rodzic
f113a692d2
commit
0f030f9ec3
|
@ -59,6 +59,7 @@ window.onload = function() {
|
|||
audio: htmlAudio,
|
||||
callback: function () { htmlAudio.play(); },
|
||||
error: function (msg) { htmlError.innerHTML = msg; },
|
||||
color: [1/32, 1, 1/32, 1],
|
||||
background: [0, 0, 0, 1],
|
||||
swap: query.swap,
|
||||
invert: query.invert,
|
||||
|
|
12
index.js
12
index.js
|
@ -13,7 +13,8 @@ let shadersDict = {
|
|||
fsProgress: glslify(__dirname + '/shaders/fsProgress.glsl'),
|
||||
};
|
||||
|
||||
let defaultBackground = [0, 0, 0, 1];
|
||||
let defaultColor = [1/32, 1, 1/32, 1],
|
||||
defaultBackground = [0, 0, 0, 1];
|
||||
|
||||
let audioCtx;
|
||||
|
||||
|
@ -49,6 +50,7 @@ function woscope(config) {
|
|||
gl: gl,
|
||||
swap: config.swap,
|
||||
invert: config.invert,
|
||||
color: config.color,
|
||||
lineShader: createShader(gl, shadersDict.vsLine, shadersDict.fsLine),
|
||||
blurShader: createShader(gl, shadersDict.vsBlurTranspose, shadersDict.fsBlurTranspose),
|
||||
outputShader: createShader(gl, shadersDict.vsOutput, shadersDict.fsOutput),
|
||||
|
@ -326,6 +328,10 @@ function drawProgress(ctx, canvas) {
|
|||
if (tmpPos && tmpPos !== -1) {
|
||||
gl.uniform1f(tmpPos, progress);
|
||||
}
|
||||
tmpPos = gl.getUniformLocation(ctx.progressShader, 'uColor');
|
||||
if (tmpPos && tmpPos !== -1) {
|
||||
gl.uniform4fv(tmpPos, ctx.color || defaultColor);
|
||||
}
|
||||
}
|
||||
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, ctx.outQuadArray);
|
||||
|
@ -423,6 +429,10 @@ function drawLine(ctx, shader) {
|
|||
if (tmpPos && tmpPos !== -1) {
|
||||
gl.uniform1f(tmpPos, 1);
|
||||
}
|
||||
tmpPos = gl.getUniformLocation(shader, 'uColor');
|
||||
if (tmpPos && tmpPos !== -1) {
|
||||
gl.uniform4fv(tmpPos, ctx.color || defaultColor);
|
||||
}
|
||||
}
|
||||
|
||||
let attribs = [];
|
||||
|
|
|
@ -5,7 +5,7 @@ precision highp float;
|
|||
#define SQRT2 1.4142135623730951
|
||||
uniform float uSize;
|
||||
uniform float uIntensity;
|
||||
precision highp float;
|
||||
uniform vec4 uColor;
|
||||
varying vec4 uvl;
|
||||
float gaussian(float x, float sigma) {
|
||||
return exp(-(x * x) / (2.0 * sigma * sigma)) / (TAUR * sigma);
|
||||
|
@ -34,5 +34,5 @@ void main (void)
|
|||
}
|
||||
float afterglow = smoothstep(0.0, 0.33, uvl.w/2048.0);
|
||||
alpha *= afterglow * uIntensity;
|
||||
gl_FragColor = vec4(1./32., 1.0, 1./32., alpha);
|
||||
gl_FragColor = vec4(vec3(uColor), uColor.a * alpha);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
precision highp float;
|
||||
uniform float uProgress;
|
||||
uniform vec4 uColor;
|
||||
varying vec2 vUV;
|
||||
float rect(vec2 p, vec2 s) {
|
||||
return max(abs(p.x)-s.x,abs(p.y)-s.y);
|
||||
|
@ -12,5 +13,5 @@ void main (void) {
|
|||
vec2 uv = vUV*size - c;
|
||||
float result = min(rect(uv,vec2(hw+5.,25.)),-rect(uv,vec2(hw+10.,30.)));
|
||||
result = max(result,-rect(uv-vec2(hw*(p-1.0),0.0),vec2(hw*p, 20.0)));
|
||||
gl_FragColor = vec4(vec3(0.1, 1.0, 0.1) * clamp(result, 0.0, 1.0), 1.0);
|
||||
gl_FragColor = uColor * clamp(result, 0.0, 1.0);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue