mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Updated filter examples
This commit is contained in:
@@ -1,32 +1,14 @@
|
||||
PShader blur;
|
||||
boolean applyFilter = true;
|
||||
|
||||
void setup() {
|
||||
size(400, 400, P3D);
|
||||
blur = loadShader(PShader.TEXTURED, "blur.glsl");
|
||||
noStroke();
|
||||
size(400, 400, P2D);
|
||||
blur = loadShader("blur.glsl");
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
lights();
|
||||
|
||||
translate(width/2, height/2);
|
||||
pushMatrix();
|
||||
rotateX(frameCount * 0.01);
|
||||
rotateY(frameCount * 0.01);
|
||||
box(100);
|
||||
popMatrix();
|
||||
|
||||
if (applyFilter) filter(blur);
|
||||
|
||||
// The sphere doesn't have blur applied on it
|
||||
// because it is drawn after filter() is called.
|
||||
rotateY(frameCount * 0.02);
|
||||
translate(150, 0);
|
||||
sphere(40);
|
||||
rect(mouseX, mouseY, 50, 50);
|
||||
filter(blur);
|
||||
}
|
||||
|
||||
void mousePressed() {
|
||||
applyFilter = !applyFilter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,32 @@
|
||||
PShader edges;
|
||||
boolean applyFilter = true;
|
||||
|
||||
void setup() {
|
||||
size(400, 400, P2D);
|
||||
edges = loadShader(PShader.TEXTURED, "edges.glsl");
|
||||
size(400, 400, P3D);
|
||||
edges = loadShader("edges.glsl");
|
||||
noStroke();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
rect(mouseX, mouseY, 50, 50);
|
||||
filter(edges);
|
||||
background(0);
|
||||
lights();
|
||||
|
||||
translate(width/2, height/2);
|
||||
pushMatrix();
|
||||
rotateX(frameCount * 0.01);
|
||||
rotateY(frameCount * 0.01);
|
||||
box(100);
|
||||
popMatrix();
|
||||
|
||||
if (applyFilter) filter(edges);
|
||||
|
||||
// The sphere doesn't have the edge detection applied
|
||||
// on it because it is drawn after filter() is called.
|
||||
rotateY(frameCount * 0.02);
|
||||
translate(150, 0);
|
||||
sphere(40);
|
||||
}
|
||||
|
||||
void mousePressed() {
|
||||
applyFilter = !applyFilter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user