Finally a free Sunday, with no hackathons, no company work & no university related work.

I started coding a rough implementation of Perlin in 2D.
Since I am porting ScaledJS to C++, need two things:
1) Port the Algorithms
2) Port the Edge Detector & Terrain Selector

Here is an initial generation algorithm for Perlin on ScaledC (C++). It’s really easy once you get to know the algorithm.

Here is a brief idea of what each function does (main ones):
Generator::GenerateMap – Generates a Noisy Map for a given set of Dimensions. (We can switch Algorithms here, like introduce DiamondSquare etc.)

Generator::Perlin – This is the Main Function for Perlin, It rotates through each octave, adds it to the total (for a x,y point). Each octave’s participation in the overall value is determined by Amplitude (Persistence from the user’s side)

Generator::generatePerlin – Main Business Logic of Perlin Noise – for a particular sample point x,y

Generator::perlinGradientFunc – Holds the Dot Product values and determines which dot product to use based on the permutation array

Generator::perlinFade – Smooths the value to near integral values

The Code Usage is given below.

auto generator = Scaled::Generator(50, 50);
generator.SetNoiseOctaves(8);
generator.SetNoisePersistence(0.7f);
generator.SetAmplitude(512);

auto map = generator.GenerateMap();

Header File:

CPP File: