I read up on this article about Perlin Noise and have a few questions if anyone has the answers because I seem to be having some issues. In the pseudo code 2D section near the bottom, it shows he randomly generates numbers but instead of one variable as a parameter in the 1D code, he now uses an ‘x’ and a ‘y’. Is this required in 2 dimensional noise or no? Also, his PerlinNoise_2D Function takes 2 float parameters now instead of 1 like in the 1 dimensional example. What are these float values supposed to be and where do they come from because I cannot find how to get them for the life of me. So if anyone knows the answers to any of my questions, I would greatly appreciate some help. Thanks.
EDIT: Ok simpler question, where do I get the 2 float values taken as parameters for the PerlinNoise_2D function?
A 2-dimensional pattern needs 2 parameters. Think of them as representing the Cartesian x and y coordinates of the pattern, in whatever way best fits your application.
So if, for example, you wanted to generate a W×H noise map in C++, you could do something like:
You could then use the
noisevalues to modulate the colour values of pixels in a bitmap, for instance.(In this example the
xandyparameters don’t need to befloats, but in the general case you might want them to be.)