I found the following example
int bmp_dim = 256;
Bitmap bmp = new Bitmap(bmp_dim, bmp_dim);
Random r = new Random(); //to create a new image every time
int thisr = r.Next(0, 5000);
for(int i=0; i<bmp_dim; i++) {
for(int j=0; j<bmp_dim; j++) {
float t = Noise2d(j+thisr, i+thisr); //offset creates
//a different image every time
if(t<0) t = -t;
if(t>1) t = 1.0f;
int fin = (int)(t*255.0f); //get in color range
Color col = Color.FromArgb(fin, fin, fin);
bmp.SetPixel(j, i, col);
}
}
[attachment=6154:img.jpg]
Heres the noise function
float Noise2d(int x, int y)
{
int n;
n = x + y * 57;
n = (n<<13) ^ n;
float res = (float)( 1.0 - ( (n * (n * n * 15731 + 789221)
+ 1376312589) & 0x7fffffff ) / 1073741824.0);
return res;
}
I took out the random offset (the variable named thisr) used to make a different noise with each compilation, and just used the x/y of the current place in the loop.
Problem is my noise seems to have patterns in it, it seems to loop. see image below (horizontal pattern)
[attachment=6155:img.jpg]
I had a look into the values and they are not the same, they dont repeat exactly from what i can see, i suspect its just the differences and intervals between them
It may look small but surely it could have adverse effects if it keeps looping, I thought the idea was that its supposed to be random and totally without patterns.
the site i got the example from has a button to generate new noise and this does not occur on the website Link here
is this meant to happen, can i fix it
cheers