05 March 2023 Perlin's Noise Algorithm What is Noise? Well if you have tried to learn about anything in procedural generation one thing you must have come across is noise! Now, what exactly is it? Well, noise is nothing but a collection of random values. To be honest, that is all there to noise at the core, but as you can guess it’s not that simple. To be a bit more technical, noise is a function. A function that takes N parameters and gives us a value following some rules(rules depend on the algorithm we are talking about). Now depending on the number of parameters we can classify noise into 1-Dimensional, 2-Dimensional, 3-Dimensional, etc. And the range of value it gives us also depends on the algorithm we are talking about. Now there are several uses for each type of noise but according to me it’s easiest to work with 2D noise while implementing the algorithms in the first place as it’s really easy to visualize. How? Through textures (images)! Once we have an algorithm setup for 2D we can generalize it to 1D, 3D, etc. (at least most of the time) Ok, so how do we generate a texture using our noise function? Here is some pseudocode: for(int i = 0 ; i < image.height ; i++) { for(int j = 0 ; j < image.width ; j++) { float n = noise( (float)j / image.width , (float)i / image.height ); n = n / NOISE_MAX; // calculate noise in range [0, 1] image.SetPixel(j, i, n, n, n); // set (R, G, B) values at pixel (j, i) } } Now now, let us see what’s going on. We loop throughout pixels and set them to the value generated by our noise function taking the x and y coordinates as input. Now you may think why am I dividing the x and y coordinates by the width and height? Well, it is to normalize them and map them to the [0, 1) range (open at one as i, j starts from 0 and goes only till width - 1, height - 1). Why do we do it? I can’t answer it just yet, so let’s just follow it blindly for now. In the future when we will be talking about applying transformations on these noise functions...
First seen: 2026-07-22 16:48
Last seen: 2026-07-22 21:52