Someone has been saying that this is not Perlin Noise. If this is not Perlin Noise, tell me how it is not. Here is a link to wiki page. It describes Perlin Noise the same way I implemented it.http://en.wikipedia.org/wiki/Perlin_noise

This is code I wrote to generate Perlin Noise.

It uses java.Random, and has a restriction of the width, height you specify. Also, it stores data in an array. It has some drawbacks, but should be enough for most uses.

if(x >= this.width) thrownewIllegalArgumentException("X specified should be between 0 and (width-1)");if(y >= this.height) thrownewIllegalArgumentException("Y specified should be between 0 and (width-1)");

/** * Rotates specified point around pivot. * @param pivot to rotate around. * @param point to rotate around pivot. * @param rotation - how many degrees to rotate. * @return a new point, which was created by rotating given point around pivot by some degrees. */publicstaticvec2point(vec2pivot, vec2point, floatrotation) {

Where else would you store your values? You need to have an array of some sort to at least throw your newly generated points using perlin noise into your terrain renderer so it can create a mesh.

The title is "Generating Perlin Noise" not "Generated Perlin Noise array". This code will allow you to calculate the output array to your liking. Perlin Noise is an algorithm to generate smooth looking noise. It is not the generated product. IT IS ALGORITHM.

Where else would you store your values? You need to have an array of some sort to at least throw your newly generated points using perlin noise into your terrain renderer so it can create a mesh.

The nice thing about actual Perlin Noise, or better actual noise algorithms is that they're deterministic.

Perlin noise is also often called a Noise Function.So what does a function actually look like?f(x) = whateveryoudowithyourxFor examplef(x) = 6x5 - 15x4 + 10x3The nice thing about this function is you can call f(10) a million times and it will always give the same result.Or generally speaking: A function that always gives the same result for the same input is called deterministic.What's nice about this? In minecraft the noise function looks like this: n(x, y, z, seed) = ...So at each position the minecraft world looks the same, as long as the seed is the same one.

Another property a function has is it's infinity.You can call f(x) with x = 1, x = 10, x = 100, x = 101000, as long as your number implementation allows it (with that I mean it wouldn't work for

int

s, i.e.). It's out of the question that the function doesn't stop at some kind of x value.What's nice about that? You can walk in one direction in minecraft almost infinitely. For generating the terrain minecraft only needs the position at which to generate whatever. It's not liminted by any width bounds or similar.

So an actual noise function (in 2D) would look like that: n(x, y, seed) = ..., or in programming terms (and if you leave out the seed):

1

publicfloatnoise(floatx, floaty) { ... }

So how would you generate an array of values out of this? Simply call it a couple of times with the array index as input.

That answer was kind of bloated but it's intention was not answering a question but giving some trivia and trying to create some 'ahaaaa' moments

PS: Ironically, with "actual" perlin noise I am talking about perlin noise that's not dependent on any canvas size and is deterministic Still perlin noise, though!

EDIT:Having fully read through the source code now, it looks like he is only a small step away from a purely deterministic implementation that isn't dependent on a specific size.

What he is doing is precomputing an array of unit vectors pointing in a random direction sequentially.What he would need to change (if he even wanted such an implementation) is get a hashing function that takes two int arguments and produces a unit vector pointing in a random direction. Thats somehow what his method

vec2g(intx, inty)

is, but it can only return random unit vectors from inside the width-height-bounds. The next step (if even wanted) would be to code some hashing magic into that function to return a random unit vector from any (x, y).

Again, his implementation is perlin noise, I'm just explaining what I mean by 'noise function' and how it would be implemented.

On infinity. It's a mathematical abstract. I can generate more unique images/terrains/whatever than you could ever look at...so it's effectively infinite even though I'd only be working with finite numbers. Look at the magnitude local wiki page.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org