Updated filter examples

This commit is contained in:
codeanticode
2012-07-24 20:20:12 +00:00
parent 08cc864b1a
commit d022a591e3
2 changed files with 31 additions and 28 deletions
@@ -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;
}