Ex Nihilo

A Processing Sketch Blog

Archive for August, 2010


Monday, August 2nd, 2010

Seems like I’m more inclined to post screenshots of work-in-progress on Dribbble these days, so you can see a few of my current experiments over there. My latest project is remixing older sketches to layer different objects and apply blur and noise filter effects.

Blur is relatively simple, Processing has a built-in blur() function that gets the job done. It’s slow, and applying multiple blurs per frame really slows down rendering, but it’s way easier to work with than the GLGraphics library. I’ll probably need to dive into the latter eventually, but for now, I’m happy to let Processing do the heavy lifting here.

Noise was simple too, although it took a few attempts to crack. I initially thought I could just use set to drop an array of black pixels on top of the scene, using a random alpha value for the opacity. Except set doesn’t appear to like alpha values, as the render would start correctly but then layer up to full black over a few frames. Which is odd because the loop would only run once, but there would be multiple frames of noise being applied. I don’t quite understand that one, but it was enough to convince me to try it another way.

Instead what I’m doing is grabbing the current colour value and using lerpColor to select a random point between it and full black. The amount variable controls how far from the original colour it will deviate, values between 0 and 0.1 tend to look best.

// amount value is amount of noise, between 0 and 1
void createNoise(float amount) {
  color c;
  for (int i = 0; i < width; i++) {
    for (int j = 0; j < height; j++) {
      color current = pixels[j * width + i];
      c = lerpColor(current, color(0, 0, 0), random(0, amount));
      pixels[j * width + i] = c;

Posted in Filters | No Comments »