noise() Vs random()

edited February 2014 in How To...

Hi, I want to discuss on the implementation and application of noise() & random().

Like here in this example

float xoff = 1.0;
void setup(){
  size(200,200);

}
void draw() {
  background(-1);
  float n = noise(xoff) * width;
  line(n, 0, n, height);
}

noise() runs only once in the draw loop where as random as shown in below example

float xoff = 1.0;
void setup(){
  size(200,200);

}
void draw() {
  background(-1);
  float n = random(xoff) * width;
  line(n, 0, n, height);
}

runs and generate dfferent values in each frame but noise() doesn't, why ? please explain how to use noise(); and why it doesn't generate new value in each frame?

Tagged:

Answers

  • _vk_vk
    edited February 2014

    Can't really explain under the hood, but to use noise you need to increment it's parameter in draw():

    float xoff = 1.0;
    void setup(){
      size(200,200);
    
    }
    void draw() {
      background(-1);
      float n = noise(xoff) * width;
      line(n, 0, n, height);
      xoff+=0.01;//tweak here 
    }
    
  • edited February 2014

    thanks _vk : On processing web referece they have mentioned that it generates random values better than random() function but problem is why doesn't it generate new value in each frame?

    Also your tweak code is the exact code mentioned on processing reference. :)

  • _vk_vk
    edited February 2014 Answer ✓

    Well this is a good place to look:

    http://natureofcode.com/book/introduction/#i6-perlin-noise-a-smoother-approach

    by Daniel Shiffman

    And the man himself : )

    http://www.noisemachine.com/talk1/index.html

    by Ken Perlin

Sign In or Register to comment.