Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perlin Noise to Percentage

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

like image 991
DiddiZ Avatar asked Jul 14 '12 22:07

DiddiZ


People also ask

How is Perlin noise calculated?

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

Is Perlin noise normally distributed?

But a perlin noise is normal distributed (ranges from -1 to 1, mean at 0) so it's not that easy.

What is lacunarity in Perlin noise?

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.

What is frequency in Perlin noise?

This will generate Perlin noise with a frequency of 1, which is the default.


1 Answers

If you want to get exactly 30% water (or some other specified value), you could do this.

  1. Generate your height-map.
  2. Place all the height-values into a list.
  3. Sort the list.
  4. Pick the value, that appears 30% into the list, as your water-level.
like image 69
Markus Jarderot Avatar answered Nov 09 '22 23:11

Markus Jarderot