noiseSeed setting


I was wondering if there’s a way to change noise seed similar to processing’s noiseSeed function.

“Sets the seed value for noise() . By default, noise() produces different results each time the program is run. Set the seed parameter to a constant to return the same pseudo-random numbers each time the software is run.”

What I’m looking for is to randomize the “noiseSeed(seed)” seed value so that I’d get a different numbers with the same ofNoise(value) value number.

e.g. ofNoise(2.0) always produces 0.5, whereas I’d like it to depend on the ‘seed nr’. Perhaps there’s a workaround that I’m missing?


So you can make an array of seeds in your setup function and then use those seeds with!show_ofSeedRandom

I tried ofSeedRandom() but this doesn’t appear to have affected the ofNoise() at all. I think it only affects ofRandom().

For example, when looking at the noise1dOctave example, they seem to just pass a different coordinate to the noise seed for each “octave” of noise they want.

// Add the most recent data, the noise value. 
// Here's where we actually fetch the noise, using ofNoise().
// Note how ofNoise() requires an argument ('t'); this is
// the coordinate (on a one-dimensional axis) whose
// corresponding noise value we wish to obtain. 
float noiseStep = noiseDataStripGroup[i].noiseStep; 
float t = (ofGetElapsedTimeMillis()/10.0 + i) * noiseStep;
data[0] = ofNoise(t);

noiseStep here is multiplied by 2 for each successive octave. So the octaves are “moving” slower or faster, but using the same seed of noise.

Running my own example, here’s what I wrote:

printf("%f, %f, %f\n", ofNoise(1), ofRandom(1), ofRandom(1));
printf("%f, %f\n", ofNoise(1), ofRandom(1));

yields the following output:

0.500000, 0.100819, 0.472745
0.500000, 0.100694

So yes, noise isn’t affected by random seeds.

So it seems the only thing openFrameworks can do is to use the same noise seed at a different point. :frowning: would love to see this feature!

hello! the old thread above is a little confusing, but for sure ofRandom and ofNoise are very different tools and a quick glance at the source indicates ofNoise seems indeed unaffected by ofSeedRandom. but it would be best to start a fresh topic stating what you want to achieve.

1 Like

ofNoise and ofSignedNoise being unaffected by the ofRandomSeed is definitely intended and sort of a feature of noise in general.

One of the main ideas for perlin/simplex noise is that the same input produces the same output.

I guess we could add a random number to all noise function inputs ( defaulting to zero ) but you could also do this by just passing an extra variable to ofNoise. ie:

float myRandomSeed = ofRandom(0, 1000); 
float noiseVal = ofNoise(t, myRandomSeed);

Hope that is helpful.

1 Like