I was playing around with perlin noise and noticed repeating patterns.
Having the ability to loop noise with such hardly noticeable seams would be a great feature but shouldn’t be occuring “naturally” here, right?
Is this something in the implementation or even something in the original algorithm or can anyone hint me to what I’m missing here?
Despite being so easy to notice and recreate I could not find anything about it in a web or forum search.
I cut down the sketch to a minimal version. I think moving the mouse while the noise is being generated might create distortions but I didn’t fix it as it’s easier to just avoid that
float noiseVal;
float noiseScale = 0.02;
void setup() {
fullScreen();
noLoop();
background(0);
colorMode(HSB, 100);
noiseDetail(6, 0.5);
}
void draw() {
if(mouseButton == LEFT) {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
noiseVal = noise(x * noiseScale, y * noiseScale, mouseX / 50.0f);
stroke(noiseVal*100);
point(x,y);
}
}
}
}
void mousePressed() {
redraw();
}
The period of the noise is highly dependant on the settings.
I’d suggest studying the reference page carefully
Another way to adjust the character of the resulting sequence is the scale of the input coordinates. As the function works within an infinite space, the value of the coordinates doesn’t matter as such; only the distance between successive coordinates is important (such as when using noise() within a loop). As a general rule, the smaller the difference between coordinates, the smoother the resulting noise sequence. Steps of 0.005-0.03 work best for most applications, but this will differ depending on use. noise() / Reference / Processing.org
Thanks but I know how noise works and normally noise is not supposed to repeat at all.
What you might be talking about is the octaves the final value is comprised of but what I showed here is that values are not simply dependant on their neighborhood but instead the whole set is plainly repeating. (At least roughly horizontally in my example image)
Perlin noise is supposed to have similar values within a limited neighborhood to generate ‘more natural’ noise but having the exact same values in fixed distances contradicts the natural look as well as the purpose of noise.
Your excerpt from the reference page is talking about the character of the noise in terms of smoothness and detail and how to affect it.
This part actually says perlin noise is working in an infinite space. This would be wrong if the result was limited to an ever repeating set of the same values.
@happymoep – unfortunately, you are misinformed. For just one example, Perlin noise is 0 at all grid points by design. It is also designed to be amenable to tiling – which is alignment repetition.
There are many related questions on the Processing forums about how to create seamless tiling with 1D or 2D Perlin noise – which is possible. You have the opposite problem – you are seeing artifacts related to repetition, and you don’t want them. One method of avoiding this is to stretch your sampling to fit within your period / octaves ratio.
Keep in mind that pseudorandom generators are pseudo-- they often have strong repetition artifacts, even when this ISN’T by design. Classic Perlin noise implementations do repeat by design in a range dependent on their period / octave settings.