How does a OpenSimplexNoise work?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JulioYagami

I need to understand it. The docs don’t explain how it really works.

:bust_in_silhouette: Reply From: Zylann

OpenSimplexNoise is a type of smooth noise algorithm like Perlin Noise: Perlin noise - Wikipedia

Noise is like random numbers spread over a grid. Like any random numbers, they can be controlled by a seed. The same seed will generate the same map.
But when you use random numbers, you get anarchic patterns where values can completely change from one pixel to another, which is not suitable for landscape generation for example.

OpenSimplexNoise instead generates a smoother pattern, like hills, and has a setting to decide how spreaded out those hills are. That’s what the period property does: if it’s 1, you get anarchic noise. But if it’s greater, it “zooms” the hills so the variations span larger areas.

But you don’t necessarily want smooth hills all the time. Maybe you want smaller hills within those hills, and further details within them.
To accomplish this, you can add together multiple layers of smooth noise, sampled at different periods: one layer with period 16 for the rough shape of the landscape, a second layer with a period of half (8) to add extra bumps at a smaller strength, and another layer with period of half again (4) for tinier details with even smaller strength.
This is why it’s said to be “fractal”, it reapplies the same algorithm multiple times at various levels of detail. Here we divided period by 2 for each layer, so that means we chose a lacunarity of 2.

Godot implementation then provides similar remaining properties:
octaves determines how many layers you want.
persistence determines how strongly the multiple layers are applied (factor 0…1).
lacunarity is the scale factor between the period of those layers.

There are plenty of resources on the internet explaining this, and there are also many variants of this algorithm.