Hello i try to increase one of pos of 2D perlin noise generator and its going wrong.
Its draws lines not “clouds” as before with lower number…
Is the some MAXIMUM number of perlin noise posX and posY ?
Here is the code:
float increment = 0.005;
void setup() {
size(640, 360);
}
void draw() {
loadPixels();
noiseSeed(0);
float xoff = 0; // Start xoff at 0
// For every x,y coordinate in a 2D space, calculate a noise value and produce a brightness value
for (int x = 0; x < width; x++) {
xoff += increment; // Increment xoff
float yoff = 1000000; // !!!! HERE IS THE VALUE WICH I CHANGE TO HIGHER... BUT... ITS NOT WORKING WELL... TRY IT YOUR SELF
for (int y = 0; y < height; y++) {
yoff += increment; // Increment yoff
// Calculate noise and scale by 255
float bright = noise(xoff, yoff) * 255;
// Try using this line instead
//float bright = random(0,255);
// Set each pixel onscreen to a grayscale value
pixels[x+y*width] = color(bright);
}
}
updatePixels();
}
Works with lower numbers, but with highers you can see in the noise some repeating… i want it for game, like in Minecraft chunk generator, how it works here ?
Alright, took another crack at this. If you add noLoop() to the setup, set float yoff to a lower number (such as 5000), and add the following code below float bright:
When you run the sketch you’ll notice that the increment works for yoff, but xoff won’t get higher than 3.2000258. Perhaps the error isn’t caused by noise, but rather by how the values are saved. Did you happen to look into this already?
EDIT: Forgot to mention that if you keep yoff at 10 000 it won’t change value, just like xoff, which might explain the outcome becomes ‘lined’ (since it’s noise(3.2000258, 10000.0); at each iteration)
Yeah, its becouse computing numbers in ALU any sequence after the long decimal point is ignored.
This is because of the accuracy of binary numbers with a decimal point.
The solution is to add a larger value to the xoff and yoff values, and then divide it to became real value and because it is more successful if you find the appropriate value to add.
Thx for everybody
There is the table with variable of tested conversion constatnts: