3

So i found a certain procedural map generator in Python and I understand parts of it but i'm having a very hard time piecing it together to be able to modify it to suite my needs so I was wondering if it is possible for someone to explain step by step what exactly the generator does. Overall I understand the concept but the way it is written makes it very hard for me to follow the math involved.

The generator is here and some explanations would be welcomed and probably help anyone else trying to learn procedural generation as this example honestly yields beautiful results.

Nick
  • 545
  • 12
  • 31
  • How about you ask the author? Also, look at the comments and changes from past commits to get an overview. – Ulrich Eckhardt Mar 10 '18 at 09:16
  • tried, even added a github issue for documentation but it seems the author has been inactive for the past year. And there are only 4 commits with the actual code being 1 commit so i can't see the changes from the past. Right now i'm adapting it to PEP8 but i'm still having trouble understanding it as if I could, I would document it myself – Nick Mar 10 '18 at 09:18
  • 3
    What part of the code are you having trouble with? From what I can understand, an initial height is generated with Perlin noise for each pixel, offset by the square root of the distance of the pixel from the center of the map (probably to make the island in the center). If the height value is larger than the arbitrary value of 0.1, it's treated as land. Otherwise, it's water. The colors for each are generated by offsetting some base color's RGB components by more Perlin noise, uniform noise, and the height. It's all arbitrary, just get the first part right and tweak the second to your liking. – Blender Mar 10 '18 at 09:40
  • 1
    You can probably get better color results by using HSV instead of RGB and applying heavy noise to the value component and slight noise to the hue and saturation. – Blender Mar 10 '18 at 09:44
  • Can you add this as an answer? I will vote on it but i want to try some things before to see if i understood correctly and if not, to just ask as a comment without having to open a new question – Nick Mar 10 '18 at 09:45

1 Answers1

1

First you must understand how Perlin Noise works. I recommend you write your own Perlin Noise code, something minimal, then play a bit with it and see the results. Then move on to more advanced techniques and variants.

Here for example the user has some settings which more or less control the output:

 basePerlinValue = (snoise2(float(x)*perlinScale, float(y)*perlinScale, octaves=8, persistence=0.5, lacunarity=2.0, repeatx=2048, repeaty=2048, base=perlinOffset) + 1)/2.0;

Play with them and see how they affect the result. Octaves is standard Perlin Noise stuff.

Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85