2

UPDATE: Formal List of questions:

  1. What do the float values (both input parameters, and the output) of a 2D noise implementation represent? - Partially answered, the inputs are the coordinates. How about the ouput? Also, can I use my integer as a float for the coords? 1.0, 122.0, etc.?
  2. What's a good way to implement a seed in a 2D noise generator? Should I just make it a 3D noise generator using the 3rd param as a seed? Would that imply each seed can generate unique 2D noise?
  3. Going along with the 2d map, generating bitmaps seems to be along the same lines. How could I generate a bitmap from the output? Presumably floats.

My questions are what do the float values (both input parameters, and output) of a cut and paste perlin noise 2D implementation represent? How could I generate a bitmap from them? If I can get a 2d array of some data type, I'm sure I could figure out how to use it to simulate my terrain.

And, I would use a cut and paste implementation, if I could ensure that I could seed the values for them. That's the other part of the question, it is an unanswered one I found here. - what's a good way to implement a seed in a noise generator?

Ok, I understand that this question has been asked many many times, so let me explain what I have researched and found.

First, I found this site here, which seemed to be a winner for explaining it to me. However, I then came up with another question which I found asked but not really answered completely here.

I then tried to get my hands dirty and code some in Java, which is my language of choice. I found this, which had me trying out the hash function given as an answer as my noise function, because I could use a seed there. Then I ran into a problem of it not returning a float to follow the rest of the processes in the tutorial. Back to the drawing board. Along the way, I found many many more sites with questions about perlin noise.

I found an unanswered question here that I hadn't even thought of yet because I haven't gotten my implementation to work. I can't find the link anymore but it said something along the lines of, even if you had a copy and pasted implementation what are the float inputs you put into the function? I was told I needed to pass INTEGERS that are my x and y on the map. I get float outputs from the cut and paste implementations as well. What do THOSE mean? How are those 2D? If I could keep things as integers it would make sense in my brain but in a way, I see that keeping them as integers would not be plausible for interpolating and smoothing the values for a continuous curve.

Community
  • 1
  • 1
user1258957
  • 121
  • 1
  • 4
  • 2
    Please edit your question. Put what you seek near the top and then explain what you already tried. – Aaron Digulla Mar 09 '12 at 10:24
  • [here](http://stackoverflow.com/questions/9546306/perlin-noise-2d-assistance) is that article I found asking a similar question! It has remained unanswered. I provided a bit more information on my attempts at finding the answer, so I'm hoping someone could take the time to answer my question. If I was able to understand it I could help this other guy out. – user1258957 Mar 11 '12 at 08:09

2 Answers2

1

1/the values are a linear or cubic interpolation in between samples random dots forming a 2d grid, so every point is a calculated balance between the 4 predetermined non calculated closest points generated by random function.

2/this is great:

function rndng ( n: float ): float
{//random linear graph -1, 1
    var e = ( n *122.459)%1;
    return  (e*e*143.754)%2-1;
}

function rnd2d ( n: float, m: float ): float
{//random 2d gooed enough for mountains -1, 1
    var e = ( n*m *31.178694)%1;
    return  (e*e*137.21321)%1;
}

if speed is not an issue, you can multiply 5-10 of them for super random function, otherwise it's the fastest on cpu, that function.

3/you have to acces the bitmap read and write library functions, and write pixels, i.e. get pixel, set pixel. to read and write bitmaps, and also create and save bitmap files and filenames.

1

As I understand the code, these are simply the coordinates for which you want the value.

Using float doesn't seem to make sense here unless you want to support zooming without jitter. Using float values, you can easily zoom into the landscape by calculating intermediate values.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • I don't intend to use any form of zooming. I have a 2D array of tiles, which I wish to determine whether or not it is ocean, sea, land, hill, mountain etc. based on the height. I choose Perlin Noise because I need it to be a continuous function. (So it looks smooth) I could input the x,y as floats (0.0, 1.0), but the output would be float? I expect the output to be a height or something equatable to height. Am I supposed to input x and y as floats, when the base noise function (One that the PerlinNoise function uses, but I don't use manually) takes ints? That part is confusing. – user1258957 Mar 13 '12 at 10:28
  • Most people who do terrain need a 3D terrain, so being able to zoom into any point of the surface is a very important. Also, when you use the noise to calculate a texture for a UV map, you need coordinates in the range `[0,1]`. The API might be confusing to you but not everyone has your use case. – Aaron Digulla Mar 13 '12 at 13:00