xxxxxxxxxx
58
let blurShader;
let thresholdShader;
let bloomBuffer;
function preload() {
blurShader = loadShader("filter.vert", "blur.frag");
thresholdShader = loadShader("filter.vert", "threshold.frag");
}
function setup() {
createCanvas(600, 600, WEBGL);
bloomBuffer = createGraphics(width, height);
noStroke();
}
function draw() {
background(255);
const t = millis()/1000;
directionalLight(255, 255, 255, cos(t/2), sin(t), -1);
translate(-100, 0, 0);
fill(255, 0, 255);
sphere(150);
translate(250, -100, -50);
fill(0, 255, 255);
sphere(50);
translate(0, 200, 100);
fill(255, 255, 0);
sphere(30);
bloomBuffer.image(get(), 0, 0);
// thresholdShader.setUniform("threshold", mouseX/width);
// bloomBuffer.filterShader(thresholdShader);
clear();
blendMode(ADD);
image(bloomBuffer, 0, 0);
blendMode(BLEND);
// blurShader.setUniform("direction", [8, 0]);
// filterShader(blurShader);
// blurShader.setUniform("direction", [0, 8]);
// filterShader(blurShader);
}