Connecting Perlin noise waves

Hi everyone, I have been trying to connect two or more waves generated with the noise() function. The idea is to get one continuous wave with specific areas having more/less noise added to them. Is there a simple way to connect two or more waves?

I would think it either requires interpolating the ending point of the first wave and the starting point of the next, or making sure that each of the waves starts and ends at the same spot. However, I have not been able to figure out both.

A simple piece of code illustrating the problem is shown below:

void setup() {
  size(800, 800);
}

void draw() {
  
  float x = 0;

  while (x < width/2) {
    point(x, 300 + 200 * noise(x / 30));
    x = x + 1;
  }
  
  while (x >= width/ 2 & x < width) {
    point(x, 300 + 100 * noise(x / 30));
    x = x + 1;
  }
}

Hello,

I was able to do this as follows:

  • Separate the plots along the x-axis
    image

  • Determine endpoint of first plot px1, py1
    Determine starting point of second plot px2, py2
    Draw a line between the two to verify
    image

  • The map function was used to transition the noise factor (nf * noise) between the ranges (px1, px2) and (200, 100) along a plot from p1 to p2
    image

Some incomplete code (was helpful for me) to get you started:

Processing Code
void settings() 
  {  
  size(600, 300); 
  }

void setup() 
  {
  strokeWeight(2);
  noLoop();
  }

void draw() 
  {
  background(0);
    
  float x = 0;
  float y = 0;
  
  stroke(255, 0, 255);
  while (x < width/2) 
    {
    y = 100+200 * noise(x / 30);  
    point(x, y);
    x = x + 1;
    }

  stroke(255, 255, 0);
  while (x >= width/ 2 & x < width) 
    {
    y = 100+100 * noise(x / 30);  
    point(x+100, y);
    x = x + 1;
    } 
  } 
  
void keyPressed()
  {    
  int seed = millis();
  //println(seed);
  noiseSeed(seed);
  redraw();  
  }

A lot of println() statements were used in writing my code for testing and debugging.

:)

Hello,

I found it much simpler to:

  • create one loop from 0 to width
  • transition the noise factor from 200 to 100 with a simple if() statement:
    if (x>200 && x<300) //from 200 to 299 
      {
      nf = nf-1; // Same as nf--
      }

And voila!

I added color to show where it was transitioning:

image

:)