Sunday, December 21, 2008

Perlin Particle 02

Adblock
Adblock

perlinParticle02_movie04
Originally uploaded by warpcat
It's been a while since I've been in Processing, but it's good to be back. Lately, most of my time has been taken up learning the Harmonica ;)

I started out trying to make a particle system to render snow falling. And I actually had pretty good results (post on that later). But in the process I wanted to add a bit of "randomness" to the snowflakes, so I started investigating Perlin noise.

In this linked movie, you can see the background cycle through the different noise maps:
  • The first background (in color), is the combined map, which is the 'x-map' in the red channel, the 'y-map' in the green channel, and the 'z-map' (speed) in the blue channel.
  • The second background is the "x-map": Lighter values move particle the the right, darker values move particle to the left.
  • The third background is the "y-map": Lighter values move the particles up, and darker values move the particles down.
  • The fourth background is the 'speed map' Lighter values speed the particles up, darker values slow the particues down.
  • The fifth background is... no background at all.
  • And finally, it loops back to the first background.
When the sketch starts, it generates the x, y, & z maps (each based on random Perlin noise) and saves them to an off-screen buffer. Then as the sketch runs, the particle queries its position on each map, and modifies its position based on the above rules.

If I get a chance to advance the code, I'm going to try to have it calculate the noise on the fly (rather than pre-generating it and saving it as multiple maps) allowing me to animate the noise over time, giving it an even more varied look.

Find source code on my Processing Wiki
Find three other movies on Flickr

No comments: