   Perlin noise
  Hello!I need some perlin noise in my application so I read this article:  Hugo Elias' Perlin Noise Article While I have understood most of the article there are some details I did not understand:1. So we basically just add up noise functions, where each noise function has an amplitude and frequency. To create such a noise function we have a pseudo random number generator that results sample points. We can scale these results by the amplitude. But I don't understand what I have to do in order to give the noise functions different frequencies. For example if I want to make 2 noise funktions. The first with frequency 2 and amplitude 10 and the second with frequency 4 and amplitude 5. So the second one has a higher frequency and thus the distance between 2 sample points is closer, isnt it? How do I express that in my code?2. In the middle of the article is a table with headline "1-dimensional Perlin Noise Pseudo code" which shows the final perlin noise code for 1D. This line is in a for loop: total = total + InterpolatedNoisei(x * frequency) * amplitudeSo here we sum up different octaves. But again I dont understand the frequency. For example if I pass x=3.4 then these values would be passed to function InterpolatedNoisei: 3.4, 3.4*2, 3.4*4, etc. Why do we multiply the sample value "x" with frequency?? 3. Last one: How do I actually create a 2D perlin noise texture. Lets say I want 6 octaves. The first one has a high amplitude and low frequency and the last one has a low amplitude and high frquency. Where do I start? Does every pixel in the "high frequency" texture gets a different random number?Thanks!   
  Point #2 is the answer to the question in point #1: if you have a function f(x) of frequency 1 then to increase the frequency then your new function is g(x) = f(x * frequency). To see an example of how this works, plot the function sin(x) and sin(2*x) on the same graph.Regarding point #3, to create the original (frequency 1) Perlin noise image you can use Perlin's own source code:http://mrl.nyu.edu/~perlin/noise/It's in 3D, but easy to adapt to 2D.   ;  I'll try to explain some of this. For some reason it's easier for me to think of it in 2D as opposed to 1D or 3D. In any case here goes.In 2D, we start out with a grid with lines on integer values. For instance there X=0, X=1, X=2 so forth. Same with Y. We also have real numbers inside the grid. Note: this grid isn't stored anywhere it's just kind of a virtual grid. In any case for any given point we can always find the four points around it by rounding down (or floor rather) for the lower points and rounding down and then adding one for the higher points. We can then feed these integer XY coordinates into our pseudo random number generator and use the result to find a random unit vector in a pre-generated table. The easiest way to generate this table is to just generate vectors around in a circle and scramble them.So now you have a random unit vector for each of the four surrounding points. We now generate a second vector for each of the same surrounding points however this one isn't random. It's simply a vector from the corner point to the point we are considering. I don't have the algorithm right in front of me but I believe we combine these two vectors with a dot product to get a final result for each of the four surrounding points. Now we combine our 4 results using one of Ken Perlin's weighting functions and get a final result for the point we are considering. Then we can scale that up to any magnitude, any way we want. That gives us one octave. To get more octaves we can multiply the coordinates of each point by some value and feed it back into the function. This moves the point to a different grid call. For instance if we had X=2.6,  Y=1.2 our initial surrounding grid points would be :(2,1) (2,2) (3,1) (3,2)giving us a particular set of random vectors. Now if multiply X and Y by 2 our point becomes X=5.2, Y=2.4 so now our surrounding grid points become:(5,2) (5,3) (6,2) (6,3)  giving us a different set of vectors. Note that the same span of XY coordinates is now scaled up so it occupies 4 times (since we are in 2D) as many grid cells as before. In any case we can add up as many octaves as we like and play with magnitude each time to get different results out of it. Hope this helps.