Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is Perlin-noise in flash implemented?

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?

like image 713
bummzack Avatar asked Dec 11 '11 21:12

bummzack


2 Answers

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.

like image 109
Superbest Avatar answered Sep 29 '22 12:09

Superbest


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...

like image 32
Andrew Odri Avatar answered Sep 29 '22 13:09

Andrew Odri