I'm desperate right now. Searched every corner and everything to figure out but i still cant.. I'm looking how to use noise to generate a tiled 2d map in java. This is the only thing i ever wanted in programming to know this. Best way to me to learn is to see the full simple code of something and analyse it by testing. Is there anyone who can show me a video or show me a simple little code of how it works? I just cant understand how to make it. Would be nice if it was in simple English because i cant really understand complex words.
You might actually want to skip Perlin Noise and look into something called OpenSimplex Noise.
Perlin Noise is an older algorithm that tends to exhibit significant grid artifacts. It tends to line up all of its features along the cardinal axes and 45-degree diagonals.
OpenSimplex Noise is useful for basically all of the same things as Perlin Noise: the noise takes an input point (in 2D, 3D, or 4D) and returns a value between -1 and 1. The output values vary smoothy with the input coordinate changes.
If you're interested in learning how the algorithm works on a technical level... basically it takes an [math]n-dimensional hypercubic tiling (squares, cubes, tesseracts, ..) and stretches it along the main diagonal in order to form a simplectic honeycomb. It then pseudo-randomly chooses gradient directions at each vertex, extrapolates them, and multiplies them by a distance-based function ("kernel") that goes to zero and stays at zero after a certain radius. An input point is "skewed" to find the effective coordinate on the hypercubic honeycomb base, then it's determined which of the shapes it's in on the simplectic honeycomb by doing shortcut math based on the hypercubic space coordinates, and from there which vertices contribute to the value at that point[/math].... But the good news is that you don't need to go into such detail in order to simply use it!
To use it, drop OpenSimplexNoise.java into your directory, and do something like this:
OpenSimplexNoise noise = new OpenSimplexNoise(); //May provide seed as argument to generate different patterns.
for (int y = 0; y < 256; y++) {
for (int x = 0; x < 256; x++) {
double value = noise.eval(x / 32.0, y / 32.0, 0.5); //2D slice of 3D at z=0.5
//Now do whatever you need to do with the value.
}
}
Here's a demo of the differences between Perlin Noise and OpenSimplex Noise: Top is Perlin, bottom is OpenSimplex. Both are 2D slices of the 3D functions. Leftmost are the basic noise(x,y,0) texture, next is black/white for negatives/positives, next is black where |noise(x,y,0)|<0.1 and white otherwise, next is noise(x,y,.5) in order to show the difference between integer and non-integer slices that is present in Perlin but not OpenSimplex.
Note that there is also an algorithm out there called Simplex Noise, which works differently than OpenSimplex Noise. Simplex Noise was developed after Perlin noise by the same guy, Ken Perlin, but unfortunately the 3D+ versions are saddled with a patent. OpenSimplex Noise is actually something I've developed on my own as part of a game development project, and made available for anyone to use.