10

Over at gamedev.SE we discovered that the flash implementation of Perlin-noise seems to deviate quite a bit from other implementations.

I didn't find any implementation details online, but I wondered if anybody can tell which algorithm is being used for Perlin-noise in flash.

Using bitmapData.perlinNoise(32, 32, 1, 200, false, false, 7, true); generates images like this where only the numOctaves parameter has been changed (1, 2, 4 from left to right):

perlin noise in flash

However other implementations of Perlin-noise look quite different. For example the image from the Wikipedia article about Perlin-noise:

Perlin noise as depicted on Wikipedia

Also this Actionscript Implementation of Perlin-noise produces quite different results, as you can see in the following images (Octaves 1, 2 and 4 from left to right):

Perlin noise AS3

What I'm mostly interested in is the look of the noise with just one octave. In the flash implementation you can clearly see, that the noise is forming something like separated blobs.

Important: The noise generated in flash uses false for the fractalNoise parameter. If fractalNoise is set to true, the results are actually very similar to the ones from Wikipedia and other implementations.

The description of the parameter reads as follows:

A Boolean value. If the value is true, the method generates fractal noise; otherwise, it generates turbulence. An image with turbulence has visible discontinuities in the gradient that can make it better approximate sharper visual effects like flames and ocean waves.

As we can see, they speak of turbulence to describe the method that generates the noise. So I guess the question is: Is that output generated by flash still Perlin-noise? Or is there another name for that kind of noise? And most importantly: Where can one find an implementation to create noise like this?

Community
  • 1
  • 1
bummzack
  • 5,805
  • 1
  • 26
  • 45

4 Answers4

4

There is some confusion about terminology, apparently. But technically, the noise that Perlin described was a single octave, without any summation. It looked like the first Wikipedia image.

I'm pretty sure almost nobody actually uses just that. Everyone adds up a few octaves, usually making amplitude larger at lower frequencies. The "how much larger" is persistence. Anyway, when you add it up, it's called fractal noise.

"Perlin noise" actually only means you make a bunch of random gradients, and interpolate them. But people refer to fractal noise as Perlin noise, because it's a sum of several Perlin noise waves.

Note that often, as in the reference implementations, Perlin and Simplex noise functions output values centered on 0 and (sometimes) scaled to [-1, +1]. Also, these are similar but not exactly identical - Simplex noise looks a bit different. They are sometimes both referred to as Perlin noise, because Ken Perlin originally thought of Perlin noise (he called it just "noise"), and then later sped it up by removing some redundancies and created simplex noise (which he called "improved noise"). Simplex can look a bit darker by itself (the grid is different so obviously it looks different) and also sections through higher-dimensional noise don't behave the same as with Perlin.

Superbest
  • 25,318
  • 14
  • 62
  • 134
1

For the ones who are still interested in Flash's perlin noise implementation, I managed to recreate it in a C library. I'm not sure it is really user-friendly, but I think it is the only implementation you can find online.

It is really accurate to Flash's perlin noise implementation: the parameters are the same and behave the same, randomSeed included.

https://github.com/NathaanTFM/as3-perlin

NathaanTFM
  • 83
  • 2
  • 8
1

it's been a looong time since I did any image processing, but maybe some of this will help:

References: (And people who know the answers...) http://www.kelvinluck.com/assets/perlin_noise_experiments/, http://www.quasimondo.com/archives/000672.php, http://www.sjeiti.com/?p=305

My understanding is that the Flash implementation is outputting results based on integer calculations rather than floats. This would explain why the rendering is fast, but also slightly different in appearance.

Hope that at least sets you in the right direction...

Andrew Odri
  • 8,868
  • 5
  • 46
  • 55
  • Sorry, but that's not it. I even used the code from one of your links to generate the images of the noise I'm *not* interested in. The flash implementation is not different because it's integer based (it's not) and if you output an image in the end, you're going to have integers, there's no way around that. The flash implementation lets you choose between "turbulence" and "regular" noise. What I'm interested in is an algorithm for **turbulence**. If you search Google images for "turbulence noise" and "perlin noise" you'll see the difference. – bummzack Dec 24 '11 at 09:11
0

I was just revisiting some of my questions here and it seems like the answer to this question was really simple all along. Assuming you have a 2D Perlin noise implementation that returns values in the range of [-1, 1], you just convert this to an absolute value (using abs) and you get the turbulence noise as a result:

images of the turbulence noise

Also see this jsFiddle for an implementation in the browser.

bummzack
  • 5,805
  • 1
  • 26
  • 45