Looping perlin noise

edited April 2018 in How To...

Hi Everyone! What would be the most simple way of fetching looping perlin noise values so that the first and last values are also related and is put around a circle gives a smooth transition. Say I need 100 values then the 1st and 100th values are related. Thanks Community. :)

Tagged:

Answers

  • Answer ✓

    Maybe use 2d Perlin noise and describe a circle around a point using x + r cos theta, y + r sin theta where theta increases in steps of two pi / 100?

  • Answer ✓

    r should be small, like much less than 1 so that the points on the noise circle are close.

  • What values do I give with noise function noise(x,y) ?

  • edited April 2018 Answer ✓

    width/2 + r cos theta, height/2 + r sin theta please

    • where theta increases in steps of two pi / 100 in a for loop
  • Answer ✓
    import peasy.PeasyCam;
    
    PeasyCam cam;
    
    float noiseScale = 0.02;
    float rad = 200;
    
    
    void setup() {
      size(777, 888, P3D);
      cam = new PeasyCam(this, 400);
      stroke(255);
    }
    
    void draw() {
    
      background(0);
    
      for (int angle=0; angle < 360; angle++) {
    
        float x= rad *cos(radians(angle));
        float y= rad * sin (radians(angle));
    
        float noiseVal =100 - 100* noise( x, y  );
    
        line (x, 100, y, 
          x, 100-noiseVal, y);
      }
    
      //
    }
    
  • For best results the steps between calls to noise should be small, like .05 small, not half the width of the screen, hence my second comment above.

    See reference: https://processing.org/reference/noise_.html

  • (And please don't post full answers before the OP has posted a single line of code.)

  • edited April 2018

    That works! Thanks @koogs, @chrisir @jeremydouglass.

    Further, what if I want to create set of ponts/lines around the circle flat on the same plane with the circle itself (visually like flat graphical sun in center with rays of different length around it).

    After that I want stack many of them in Z axis such that each endpoint is related to those above, below, left and right of it. Also the first and last point on each are also related . I am writng code that uses 3-Dimensional noise for implementing above. Would that be a good idea?

    Hope, I was able to give enough information to visualize my case.

    Thanks a lot :)

  • edited April 2018

    I want stack many of them in Z axis such that each endpoint is related to those above, below, left and right of it. ... I am writng code that uses 3-Dimensional noise for implementing above.

    You could use 3D noise for this -- or just 2D noise.

    A line of noise is 1D. You can wrap that line as wobbly perturbations of a circle -- or as rays of a starburst. Each pixel in the 1D line of noise is a radius value.

    Many lines is 2D. You can use each line for a different wobbly circle -- many lines across a 2D Perlin tile may define a stack of circles.

    Share your code for more feedback.

  • Answer ✓

    A line of noise is 1D. You can wrap that line as wobbly perturbations of a circle -- or as rays of a starburst. Each pixel in the 1D line of noise is a radius value.

    yeah, but the end of the 1d line won't match the start of the 1d line - the looping in the original question. so use a circle in 2d noise space as the noise value.

    and for a tower of circles use 3d noise space.

  • edited April 2018 Answer ✓

    @koogs -- re:

    the end of the 1d line won't match the start of the 1d line

    That isn't true in the 2D example I gave -- they will match. See:

    https://forum.processing.org/two/discussion/26962/how-to-close-a-noisy-circular-shape

    If the Perlin noise settings generate a 2D tile then any 1D horizontal or vertical line sampled from the 2D tile will always wrap perfectly, and any set of horizontal or vertical line samples will form the tower.

    You could do this with an arbitrary 3D Perlin noise field as well by sampling points in a tube shape out of the field, but the repeating tile is both easier to sample and comes with a nice bonus property -- if the sampled lines are evenly spaced across the tile then the top and bottom circles of the stack also wrap on the z axis -- which I think might be what OP meant by?:

    each endpoint is related to those above, below, left and right of it. Also the first and last point on each are also related

    Unless this referred to the beginning and end of each ray line.

Sign In or Register to comment.