xxxxxxxxxx
74
// the shader variables
let camShader1;
let camShader2;
let camShader3;
// the camera variable
let cam;
// the camera textures (for multipass)
let camg1;
let camg2;
let camg3;
let testimg;
const testimg_w = 1538;
const testimg_h = 2048;
function preload(){
// load the shader
camShader1 = loadShader('effect.vert', 'effect.frag');
camShader2 = loadShader('effect.vert', 'effect.frag');
camShader3 = loadShader('effect.vert', 'effect.frag');
testimg = loadImage('test.jpeg');
}
function setup() {
// shaders require WEBGL mode to work
createCanvas(windowWidth, windowHeight);
camg1 = createGraphics(width, height, WEBGL);
camg1.noStroke();
camg2 = createGraphics(width, height, WEBGL);
camg2.noStroke();
camg3 = createGraphics(width, height, WEBGL);
camg3.noStroke();
// initialize the webcam at the window size
cam = createCapture(VIDEO);
cam.size(windowWidth, windowHeight);
// hide the html element that createCapture adds to the screen
cam.hide();
// camg3.image(testimg, -width / 2, -height / 2, width, height);
}
function draw() {
camg1.shader(camShader1);
camShader1.setUniform('tex0', testimg);
camShader1.setUniform('iResolutionX', testimg_w);
camShader1.setUniform('iResolutionY', testimg_h);
camg1.rect(0, 0, width, height);
camg2.shader(camShader2);
camShader2.setUniform('tex0', camg1);
camShader2.setUniform('iResolutionX', testimg_w);
camShader2.setUniform('iResolutionY', testimg_h);
camg2.rect(0, 0, width, height);
camg3.shader(camShader3);
camShader3.setUniform('tex0', camg2);
camShader3.setUniform('iResolutionX', testimg_w);
camShader3.setUniform('iResolutionY', testimg_h);
camg3.rect(0, 0, width, height);
image(camg3, 0, 0);
// image(camg3, width / 2, 0);
}
function windowResized(){
resizeCanvas(windowWidth, windowHeight);
}