|
|
@@ -998,6 +998,204 @@ class AUECHO extends Shader { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
SLITSCAN |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
class SLITSCAN extends Shader { |
|
|
|
int[] fx; |
|
|
|
int[] fy; |
|
|
|
float[] phx; |
|
|
|
float[] phy; |
|
|
|
int[] sx, sy; |
|
|
|
boolean[] skipfx; |
|
|
|
boolean[] skipfy; |
|
|
|
boolean dox, doy; |
|
|
|
PImage buffer; |
|
|
|
float[][] ft = new float[2][32]; |
|
|
|
int depth; // number of octaves |
|
|
|
int fxnum; |
|
|
|
int fynum; |
|
|
|
SLITSCAN() { |
|
|
|
name = "fxSlitSscan"; |
|
|
|
buffer = createImage(renderer.width, renderer.height, ARGB); |
|
|
|
for (int i=0; i<32; i++) { |
|
|
|
ft[0][i] = pow(2.0, i); |
|
|
|
ft[1][i] = 0.5*1.0/ft[0][i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
void animate() { |
|
|
|
|
|
|
|
buffer.resize(renderer.width, renderer.height); |
|
|
|
buffer = renderer.get(0, 0, renderer.width, renderer.height); |
|
|
|
int s = buffer.width>buffer.height?buffer.height:buffer.width; |
|
|
|
depth = (int)(log(s)/log(2)); |
|
|
|
fxnum = (int)random(depth); |
|
|
|
fynum = (int)random(depth); |
|
|
|
|
|
|
|
|
|
|
|
fx = new int[fxnum+1]; |
|
|
|
fy = new int[fynum+1]; |
|
|
|
sx = new int[fxnum+1]; |
|
|
|
sy = new int[fynum+1]; |
|
|
|
|
|
|
|
phx = new float[fxnum+1]; |
|
|
|
phy = new float[fynum+1]; |
|
|
|
|
|
|
|
skipfx = new boolean[fxnum+1]; |
|
|
|
skipfy = new boolean[fynum+1]; |
|
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<fxnum; i++) { |
|
|
|
//fx[i]=(int)random(6); |
|
|
|
fx[i]=(int)random(6); |
|
|
|
phx[i] = random(1); |
|
|
|
skipfx[i] = random(1)<0.2; |
|
|
|
sx[i] = random(1)<0.2?-1:1; |
|
|
|
} |
|
|
|
for (int i=0; i<fynum; i++) { |
|
|
|
fy[i]=(int)random(6); |
|
|
|
//fy[i]=6; |
|
|
|
phy[i] = random(1); |
|
|
|
skipfy[i] = random(1)<0.2; |
|
|
|
sy[i] = random(1)<0.2?-1:1; |
|
|
|
} |
|
|
|
dox = random(1)<0.8; |
|
|
|
doy = dox?random(1)<0.8:true; |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
void apply() { |
|
|
|
renderer.beginDraw(); |
|
|
|
renderer.colorMode(RGB); |
|
|
|
renderer.noStroke(); |
|
|
|
colorMode(RGB); |
|
|
|
renderer.fill(255); |
|
|
|
|
|
|
|
// buffer = createImage(renderW, renderH, ARGB); |
|
|
|
buffer.resize(renderer.width, renderer.height); |
|
|
|
buffer = renderer.get(0, 0, renderer.width, renderer.height); |
|
|
|
// int s = buffer.width>buffer.height?buffer.height:buffer.width; |
|
|
|
// depth = (int)(log(s)/log(2)); |
|
|
|
// fxnum = (int)map(knobZero, 0, 255, 0, depth); |
|
|
|
// fynum = (int)map(knobOne, 0, 255, 0, depth); |
|
|
|
// fx = new int[fxnum+1]; |
|
|
|
// fy = new int[fynum+1]; |
|
|
|
// sx = new int[fxnum+1]; |
|
|
|
// sy = new int[fynum+1]; |
|
|
|
// |
|
|
|
// phx = new float[fxnum+1]; |
|
|
|
// phy = new float[fynum+1]; |
|
|
|
// |
|
|
|
// skipfx = new boolean[fxnum+1]; |
|
|
|
// skipfy = new boolean[fynum+1]; |
|
|
|
// |
|
|
|
// |
|
|
|
// for (int i=0; i<fxnum; i++) { |
|
|
|
// fx[i]=(int)random(6); |
|
|
|
// phx[i] = random(1); |
|
|
|
// skipfx[i] = random(1)<0.2; |
|
|
|
// sx[i] = random(1)<0.2?-1:1; |
|
|
|
// } |
|
|
|
// for (int i=0; i<fynum; i++) { |
|
|
|
// fy[i]=(int)random(6); |
|
|
|
// phy[i] = random(1); |
|
|
|
// skipfy[i] = random(1)<0.2; |
|
|
|
// sy[i] = random(1)<0.2?-1:1; |
|
|
|
// } |
|
|
|
// dox = random(1)<0.8; |
|
|
|
// doy = dox?random(1)<0.8:true; |
|
|
|
// } else { |
|
|
|
// println("ratatata"); |
|
|
|
// buffer = createImage(renderW, renderH, ARGB); |
|
|
|
// buffer = renderer.get(0, 0, renderer.width, renderer.height); |
|
|
|
|
|
|
|
|
|
|
|
float v=0; |
|
|
|
for (int y=0; y<buffer.height; y++) |
|
|
|
for (int x=0; x<buffer.width; x++) { |
|
|
|
float iy = map(y, 0, buffer.height, 0, 1); |
|
|
|
|
|
|
|
v=0; |
|
|
|
if (doy) for (int i=0; i<fy.length; i++) |
|
|
|
if (!skipfy[i]) v+=sy[i]*getValue(fy[i], iy, i, phy[i]); |
|
|
|
|
|
|
|
float ry = 2*iy+v; |
|
|
|
float y2 = (3*buffer.height+ry * buffer.height/2)%buffer.height; |
|
|
|
|
|
|
|
float ix = map(x, 0, buffer.width, 0, 1); |
|
|
|
v=0; |
|
|
|
if (dox) for (int i=0; i<fx.length; i++) |
|
|
|
if (!skipfx[i]) v+=sx[i]*getValue(fx[i], ix, i, phx[i]); |
|
|
|
|
|
|
|
|
|
|
|
float rx = 2*ix+v; |
|
|
|
float x2 = (3*buffer.width+rx * buffer.width/2)%buffer.width; |
|
|
|
|
|
|
|
renderer.fill(buffer.get((int)x2, (int)y2)); |
|
|
|
renderer.rect(x, y, 1, 1); |
|
|
|
} |
|
|
|
renderer.endDraw(); |
|
|
|
} |
|
|
|
|
|
|
|
float getValue(int fun, float idx, int freq, float phase) { |
|
|
|
switch(fun) { |
|
|
|
case 0: |
|
|
|
return getSin(idx, freq, phase); |
|
|
|
case 1: |
|
|
|
return getSaw(idx, freq, phase); |
|
|
|
case 2: |
|
|
|
return getTriangle(idx, freq, phase); |
|
|
|
case 3: |
|
|
|
return getCutTriangle(idx, freq, phase); |
|
|
|
case 4: |
|
|
|
return getSquare(idx, freq, phase); |
|
|
|
case 5: |
|
|
|
return getNoise(idx, freq, phase); |
|
|
|
default: |
|
|
|
return getSin(idx, freq, phase); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
float getNoise(float idx, int freq, float phase) { |
|
|
|
return 2*ft[1][freq]*(noise((idx+phase)*ft[0][freq])-0.5); |
|
|
|
} |
|
|
|
|
|
|
|
float getSin(float idx, int freq, float phase) { |
|
|
|
float p = ft[0][freq]; |
|
|
|
return ft[1][freq] * sin(idx*TWO_PI*p+phase*TWO_PI); |
|
|
|
} |
|
|
|
|
|
|
|
float getSaw(float idx, int freq, float phase) { |
|
|
|
float p = ft[0][freq]; |
|
|
|
float rp = 2.0*ft[1][freq]; |
|
|
|
float p2 = p*((idx+phase+ft[1][freq])%1.0); |
|
|
|
return rp*(p2-floor(p2)-0.5); |
|
|
|
} |
|
|
|
|
|
|
|
float getSquare(float idx, int freq, float phase) { |
|
|
|
float p = ft[0][freq]; |
|
|
|
float rp = ft[1][freq]; |
|
|
|
return (((idx*p)+phase)%1.0)<0.5?rp:-rp; |
|
|
|
} |
|
|
|
|
|
|
|
float getTriangle(float idx, int freq, float phase) { |
|
|
|
return 2*abs(getSaw(idx, freq, phase+0.5*ft[1][freq]))-ft[1][freq]; |
|
|
|
} |
|
|
|
|
|
|
|
float getCutTriangle(float idx, int freq, float phase) { |
|
|
|
return constrain(getTriangle(idx, freq, phase), -ft[1][freq+1], ft[1][freq+1]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|