NOTE: This generator is only useful if you were looking for Value Noise in the first place and know what you want to do with it!
What is this? Edit
This is "Value Noise". It's an image generated by the computer (or in this case, PTC) which is "random but controlled". Regular random noise just looks the static on CRTs when you don't have a channel; we don't want this. However, value noise has a lot of uses; hopefully you can already see how the above image can be used in games. At the simplest level, it kind of looks like clouds, so there you go. However, if we were to take this value noise and apply filters to it, we could generate terrain or apply it to textures to make them look dirty or more realistic. This would usually take a computer almost no time at all to generate, but unfortunately PTC takes QUITE a long time.
The Generator Edit
The generator that I've created stores the noise values in a 2D array. This way, you don't have to try to pull the data from an image; you can just use the noise directly from the array. All values are normalized to real numbers in the range of 0-1. It also has a function which draws this array to the screen in case you want to see it. If you're looking for value noise, you probably don't need it to draw anything.
The steps are:
- Color - Initialize the GRP color space so it's grayscale (not actually part of noise generation)
- Init - Initialize the random array necessary for noise generation (important)
- Noise - Generate the actual noise values and store them in the array (important)
- Normalize - Normalize noise values to real numbers in the range 0-1 (usually important)
- Draw - Draw the resulting noise to the screen
The code is only 100 lines long, and quite a bit of that is just the drawing fluff that you probably don't need if you're just looking for noise. The main functions follow the 5 steps of the generator, so use the descriptions above as a guide.
I can't really explain how Value Noise works; if you need an explanation, look here:
- http://devmag.org.za/2009/04/25/perlin-noise/ (short but focused on gaming)
- http://freespace.virgin.net/hugo.elias/models/m_perlin.htm (long winded for those who want to know everything)
Both of those websites mistakenly refer to it as "Perlin" noise, but trust me, it's not. Perlin noise is quite a bit more complicated than what we're doing here.
"Linear Interpolation" or "LERP" is just a way to get a given point in between two points. For instance, the point right in the middle of 1 and 3 is 2. The point that's 0.25 between 1 and 3 is 1.5. There's a function called "GETPOINT" which gets an interpolated point from the pre-generated random space (using that array we created in the "Init" phase). GETPOINT will NOT give you an arbitrary point of value noise for any given point; this function must be called multiple times at different "octaves" to generate what you see.
If you just want to play around with it, definitely load it up in the "edit program" section instead of "view programs", since the program takes a VERY long time to generate an image, and then it immediately quits. Please be ready to wait at least a couple minutes for it to generate the noise.