How to change the noise of Perlin [see Stream example]

I use Perlin Noise for a global generator in 2D (like in Terraria). I found an implementation that suits me. I need to generate parts of the world, but this implementation can only generate once all over the world.

Implementation - http://sirisian.com/javascriptgame/tests/valuenoise2.html I rewrote it AS3, slightly changing (+ main code) - http://codepad.org/crMEQ2DD

Please help change the code so that you can create the noise part:

PerlinNoise.randomize(65735);
...
var noises:Vector.<Number> = PerlinNoise.getNoise(0, 0, 100, 100, 6, 6, 1.0, 20);
...
var noises:Vector.<Number> = PerlinNoise.getNoise(100 /*<--x offset*/, 0, 100, 100, 6, 6, 1.0, 20);

I tried several options, but different noise parts did not dock.

And if you have a Perlin Noise implementation that is suitable for a world generator, you can pass it to me.

Thank!

+5
source share
1

Flash Perlin, BitmapData.perlinNoise(). , ( ), BitmapData.getVector(), 32- , , , .

, . , .

public static function initNoiseVector(output : Vector.<Number>, baseX : Number, numOctaves : Number, scale : Number, blur : uint = 0) : void
{
    var i : uint;
    var len : uint;
    var sum : uint;
    var avg : uint;
    var perlin : BitmapData;
    var noise : Vector.<uint>;

    len = output.length;

    perlin = new BitmapData(len, 1);
    perlin.perlinNoise(baseX, 1, numOctaves, 0, true, false, 7, true);

    if (blur > 0)
        perlin.applyFilter(perlin, perlin.rect, new Point(), new BlurFilter(blur, 1, 3));

    noise = perlin.getVector(perlin.rect);

    // Calculate average
    sum = 0;
    for (i=0; i<len; i++) {
        // Mask out blue channel
        sum += noise[i]&0xff;
    }
    avg = sum/len;

    for (i=0; i<len; i++) {
        var speed : Number;

        // Convert perlin noise color to value between -1 and 1
        speed = ((noise[i]&0xff) - avg) / avg;
        output[i] = speed * scale;
    }
}

1px ( ), Perlin , , .

( , - , ). -1 1, 0 .

, 1000 :

_noise = new Vector.<Number>(1000, true);
PerlinNoiseUtil.initNoiseVector(_noise, 300, 10, randomDev * periodTime, 10);

, !

+2

All Articles