We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Unable to change back noiseDetail(falloff)
Page Index Toggle Pages: 1
Unable to change back noiseDetail(falloff) (Read 960 times)
Unable to change back noiseDetail(falloff)
May 3rd, 2010, 3:22pm
 
Hi,

I've been trying out different noise/random functions. I started to use noiseDetail, but something happened that I can't explain and after searching inside the code it turned out it was the falloff, which remains changed onces changed. See the code example below.

Processing 1.09.

Please tell me if I am doing something wrong or if this is a bug. Thanks.

Jaden


Code:

void setup() {
 size(100,100);

 // noiseDetail falloff set to 0
 // output ranges between 0 and 1
 for (int i=0; i<3;i++) {
   noiseDetail(4,0);
   float x = noise(i);
   println(x);
 }

 // noiseDetail falloff set to 25
 // output ranges in the 100s and 1000s
 for (int i=0; i<3;i++) {
   noiseDetail(4,25);
   float x = noise(i);
   println(x);
 }

 // noiseDetail falloff set to 0 again
 // but output STILL ranges in the 100s and 1000s!
 for (int i=0; i<3;i++) {
   noiseDetail(4,0);
   float x = noise(i);
   println(x);
 }

}

void draw() {
 exit();
}
Re: Unable to change back noiseDetail(falloff)
Reply #1 - May 4th, 2010, 12:56am
 
The falloff factor is a percentage, so you shouldn't go above 1:
Quote:
Any value between 0.0 and 1.0 is valid, however note that values greater than 0.5 might result in greater than 1.0 values returned by noise().

Now, there is a real bug in the function, as it changes the falloff only if it is strictly greater than zero. I think the test should be >= 0
The workaround is to give a falloff of 0.0001 for example.

I found no bug related to falloff nor noiseDetail, so I will report it.
[EDIT] On second thought, looking (quickly) at the noise algorithm, a null falloff value is probably bad...
So I think that's the doc that should be more precise. Will report that instead... => Done: More information on noiseDetail reference
Re: Unable to change back noiseDetail(falloff)
Reply #2 - May 4th, 2010, 5:06am
 
...am only confirming/restating philo's reply...

Your first block, with falloff==0, fails to set the falloff, because it's zero.
Your second block, does set the falloff to 25 (an unusual, but allowable, value)
Your third block again fails to set the falloff,  because it's zero.

Recode your blocks using (for example) the values 0.1,0.75,0.3 and you should note a difference in each block.

A falloff of zero means subsequent octaves would give NO additional contribution, so it's a "nonsense" value -- it is equivalent to calling noiseDetail(1) *without* concern for the falloff value.

OTOH, falloff values are *not* checked to be <= 1.0 (though the reference might suggest they are).  But values > 1.0 produce higher amplitudes in the higher octaves, which is the opposite of how most people expect a Perlin noise function to behave.  (such noise will be very 'noisy', less smooth that you might expect)

Further, falloffs >0.5 will return values outside the 0..1 range - that's why your values are in the 100's and 1000's using a falloff of 25.  If you DO wish to "scale" the returned values into the 100's, you should instead do something like:
float x = noise(i) * 100.0;

hth
Re: Unable to change back noiseDetail(falloff)
Reply #3 - May 4th, 2010, 5:13pm
 
Thanks PhiLho and davbol. It's become a lot clearer now. I think adding some of this info to the reference would indeed be a good idea.

As I said, I was getting to know and comparing different methods for generating (semi-)random numbers. Here's what my explorations have led me to so far...

Smiley

Screenshot:
http://img192.imageshack.us/img192/4131/processingh.jpg

Vimeo video:
http://www.vimeo.com/11477222
Page Index Toggle Pages: 1