Typically when generating seamless Simplex noise the strategy is to go to 4-dimensions (a strategy which has worked well for me in the past when using 2-D Simplex), however I am trying to generate a seamless GIF loop using 1-D simplex noise (only interested in the noise specifying the Y-value in a line graph).
I'm curious if I'm either misunderstanding how to make things seamless in 1-D or if I possibly have an error in logic here. Basically, I'm generating a 2-D array, where the first dimension is the Z axis and the second dimension is a list of the points (x-y values) for that Z. I iterate over each z and simply plot each vertex in turn.
What I notice is that, when I hit my maximum Z-value, there is a clear jump indicating that I'm doing something wrong (not seamless).
I'm using the fast-simplex-noise library (I like it better than P5's built-in noise function) and specify it as so:
function setup() {
let freq = 0.005;
let octaves = 14;
_noise = new FastSimplexNoise({ frequency: freq, octaves: octaves });
// specify the points:
points = [];
step = 0;
maxSteps = 150;
let r = 1.0;
for (let z = 0; z < maxSteps; z++) {
let t = (1.0 * z) / maxSteps;
points[z] = [];
for (let x = o + 10; x < width - o - 10; x++) {
let _n = _noise.get4DNoise(x, z, r*cos(TWO_PI*t), r*sin(TWO_PI*t));
let _y = height/2 + 250*_n;
points[i].push({ x: x, y: _y });
}
}
}
In the draw function I simply iterate over each vertex in the points list and keep track of the current z value per-draw iteration.
It sounds like you are expecting the change in noise values when jumping from
z = maxSteps - 1toz = 0to be small. However this is not going to be the case when you specifyzas the second parameter toget4DNoisebecause while the third and fourth dimensions will be quite close to each other for these two values ofz(thanks to the use of sine and cosine), the second will differ bymaxSteps - 1. This begs the question: why are you using 4D noise at all? You are trying to varyyrandomly such that it is smoothly changing for changes in eitherzorxand also looping back around. In order to achieve this you simply need to sample noise values along a straight line in 3d space moving around a cylinder.Here's a visualization of your noise algorithm, and a very similar one that only uses 3d noise. Notice how the cylinder on the left has a seam, but the one on the right has no seam: