When I started doing processing I fell in love with the Perlin noise function. A little while later Flash 8 came out including noise. But I was a bit disappointed in their noise implementation, since it was only (and still is) a BitmapData function (without falloff). Perlin noise can be used for much than just bitmaps. Of course you could just getpixel the generated noise data but that only gives you integer noise values.
So I did what I always wanted to do but never did (because I thought it would be too difficult): wrote a Perlin noise class. Actually I just ported the main part from Ken Perlin’s improved noise. But I still had to implement octaves, falloff and seed. The function now looks like Perlin.noise(x:Number,y:Number,z:Number):Number. I’d also like to insert a fourth dimension in there. So we would have three spacial- and one time dimension.

Flash does calculate it’s noise about a hundred times faster than this class does. So if you’re ok with integer input values for noise you might be better off getpixeling the noise data than using this class. But I don’t claim to be the god of code either; there is probably a lot that could be done to optimize this class. So if you have any suggestions please comment.

In the next example the bitmaps are created with the new noise function and setpixel. I’ve set the octaves horizontally and the falloff vertically. The first row has the same falloff as the second but a different seed for each bitmap. The x and y positions of the little ball are also controlled by Perlin noise with an octave of two and a falloff of one half. Click to view example
Here’s the download containing the above example. Things should become clear from the source code. If you still have any questions feel free to comment.
Here’s another example with multiple balls. Each cycle the balls gravity is calculated by feeding it’s position into the noise function. The collision in this example is managed by APE

There was a slight error in the falloff calculation. I’ve updated the download (version 1.2).

-another update-
Mario Klingemann made some optimizations. The class is now almost twice as fast! I haven’t had time to update my downloads yet so in the meantime get the optimized version here


  1. Seb Lee-Delisle » Blog Archive » 3D Perlin noise in Flash

    […] thankfully this nice chap Ron Valstar has just converted it into […]

  2. Steamboy » Blog Archive » Experiment #3

    […] only does 2d. Seb Lee-Delisle has been doing some experiments using a custom Perlin Noise class, by Ron Valstar. I decided to roll my own Now, what I’ve come up with has a few problems – first of all you can’t […]

  3. Evan

    Hi Ron,

    Nice site…thanks for your informative posts…

    I have been trying to implement Seb’s z slicing technique to animate the noise while using your 3D Perlin Noise class but to no avail. Your source example has the Perlin.noise(x, y, z) static method return a Number …. when I onEnterframe with a recall to Perlin.noise with a change in the z parameter I just get a really jerky anim and nowhere near as good looking as Seb’s.

    Seb animated 3dperlin noise involves a z-slicing of a “blob” of noise. Any tips how do to that?

    Is there a way to just call Perlin.noise once and then slice from there?

    May you please provide some more tips or source code.

    thanks again,

    Evan from Canada

  4. Sjeiti

    Hi Evan,

    The noise class is as fast as I could get it, so it’s probably better for single point calculations (like the APE example) than entire blobs.
    Sebs blobs calculates only one slice per frame and animates those over the planes. What could also speed it up is a low number of octaves and a not too big a bitmap.

    have fun,

    Ron from the Netherlands

  5. nodename » Perlin Clouds and Frocessing (with an F)

    […] fall, built with two different Flash implementations of 3D Perlin noise. The one on the right uses Ron Valstar’s Perlin class (as does Seb’s demo), which appears to be a faithful port of Ken Perlin’s Improved […]

  6. Mario Klingemann

    I followed your invitation and optimized the class a bit. So this new version is almost twice as fast: http://www.quasimondo.com/examples/OptimizedPerlin.as

  7. Sjeiti » Blog Archive » Perlin Noise and Frocessing

    […] cool nonetheless. Another little newsflash in that first post is that Mario Klingemann optimized my original Perlin Noise class. It’s now almost twice as fast! Funny how two simple things (type casting and unrolling […]

  8. Optimizing Perlin Noise | Learn Flex 3.0

    […] todays post on nodename about Perlin Clouds and Frocessing I came across Ron Valstar’s AS3 version of Ken Perlin’s Improved Noise reference implementation which I must have missed last […]

  9. Fingerprints by Anatoly Zenkov « byK

    […] note: Free Perlin noise class for AS3.0 from Sjeiti. Share and […]

  10. actionscript microcosmos » haXe´d PerlinFlow on Memory

    […] is a BitmapData function only. Therefore, remedy comes quite a long time ago (2007) in the form of Ron Valstar and in an even more optimized perlin noise version by Mario Klingemann. Fair enough so far! But […]

  11. Sjeiti :: noise r us «

    […] sjeitiauthors: Ron Valstar and Mario Klingemanspeed: 60 […]

  12. Karey Helms » Fingerprints by Anatoly Zenkov

    […] note: Free Perlin noise class for AS3.0 from […]

  13. Corey

    Great article! I wanted to ask you about the “scale” input on the second example. Where in the equation does that get worked into?

    I identify this as the main part of the noise function
    s += n((x+iXoffset)*fFreq,(y+iYoffset)*fFreq,(z+iZoffset)*fFreq) * fPers;
    Where would I fit scale into? It looks like its where fPers should go but I’m not sure.

  14. Inear – Flash Development » Ridged Perlin Noise

    […] Optimized Perlin Noise seen in the community before. I think the route of that source began with Ron Valstar’s AS3 version (@Sjeiti), then with a optimized version by @quasimondo, and further optimized with a haxe-version […]

  15. noise r us - Sjeiti

    […] sjeitiauthors: Ron Valstar and Mario Klingemanspeed: 60 […]

  16. Perlin Noise and Frocessing - Sjeiti

    […] cool nonetheless. Another little newsflash in that first post is that Mario Klingemann optimized my original Perlin Noise class. It’s now almost twice as fast! Funny how two simple things (type casting and unrolling […]

  17. Stars and Clouds in Away 3D 4.0 | blog.sokay.net | flash game development discussion

    […] created the clouds with noise. To get “3D slices” I used a 3d Perlin noise generator by Ron Valstar. The regular Flash noise class lets you generate noise on X and Y axis, this allows you to move in […]

  18. 3D Perlin noise in Flash | Seb Lee-Delisle

    […] thankfully this nice chap Ron Valstar has just converted it into […]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>