I'm coding a map generator based on a perlin noise and ran into a problem:
Lets say I would want 30% water and 70% dirt tiles. With a usual random generator there is no problem:
tile = rnd.nextFloat() < 0.7f ? DIRT : WATER;
But a perlin noise is normal distributed (ranges from -1 to 1, mean at 0) so it's not that easy.
Does anyone know a way to transform a normal to an uniform distribution or a different way I could get a percentage from a noise value?
EDIT: The 70% are just an example, I'd want to be able to use any value dynamically, at best with 0.1% precision.
EDIT2: I want to transformate perlin noise to a uniform distribution, not to normal (which it already is alike).
Perlin's method split the integer space into 256x256x256 cubes and then uses a random permutation of these cubes to shuffle them, and then each cube position corners is assigned one of twelve directions to the neighboring non-permuted cubes in a 4x4x4 paving space: this requires only integer operations but maintains a ...
But a perlin noise is normal distributed (ranges from -1 to 1, mean at 0) so it's not that easy.
Lacunarity. A multiplier that determines how quickly the frequency increases for each successive octave in a Perlin-noise function. The frequency of each successive octave is equal to the product of the previous octave's frequency and the lacunarity value.
This will generate Perlin noise with a frequency of 1, which is the default.
If you want to get exactly 30% water (or some other specified value), you could do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With