ofxNoise

Hi.
just ported the noise classes by Karsten Schmidt into an OF addon.
i changed a few things here and there but its pretty much the same code.

it has perlin noise in 1, 2 and 3 dimensions
and simplex noise in 2, 3 and 4 dimensions

you can get it here: ruicode.googlecode.com

looks cool,

checkout http://ofxmsaof.googlecode.com/svn/trun-…-Noise/src/

there is a ofxPerlin.h aswell. they might combine nicely :slight_smile:

that looks cool. I was using some perlin and simplex noise classes found on the net until now.

@lian, never knew that one existed, otherwise i probably would have just used that one instead :slight_smile:

@moka yeah i was using a perlin noise class that i got found online but it was kinda old and not very optimised. hopefully these will be a lot better.

hey pelintra!

I was using this and think I found a glitch in noiseuf. despite claiming that it returns values between 0…1 it was giving me the same as noise ( that is, -1…1)

Not sure why, but think that the reason was that you had a couple of return statements missing from noiseuf (in teh 2d and 3d version).

was like that

  
  
  
float ofxPerlin::noiseuf(float x){  
	float res = noise(x);  
	res *= 0.5f;  
	res += 0.5f;  
	return res;  
}  
  
float ofxPerlin::noiseuf(float x, float y){  
	float res = noise(x, y);  
	res *= 0.5f;  
	res += 0.5f;  
	  
}  
  
float ofxPerlin::noiseuf(float x, float y, float z){  
	float res = noise(x, y, z);  
	res *= 0.5f;  
	res += 0.5f;  
	  
}  
  

I added the return statements and now it works as advertised. Thanks a lot for the class!

best,
jesús.

yes you’re right!!! :expressionless:
don’t even know how i missed that, sorry.
i’ve uploaded a corrected version.

hey rui.

I think something is missing in the conversion from toxi’s class. I wasn’t noticing any change (apart from a drop in fps) when altering the octaves and falloff params in noiseDetail, so after some fiddling I tried toxi’s p5 class to compare. Consider this simplified drawing code (very similar to what you had in the example.

  
  
ofBeginShape();  
	ofVertex(0, ofGetHeight()/2);  
	for(int i=0; i<300; i+=2){		  
		ofVertex(  
			i*(ofGetWidth()/300.0f),   
			(ofGetHeight()/2) +  noise->noise(i*0.05f, ofGetFrameNum()/100.0f)*100  
		);  
	}  
	  
	ofVertex(ofGetWidth(), ofGetHeight()/2);  
	ofEndShape();  
  

This is the result I get with ofxNoise in of (top) and with toxi’s math.noise in p5.

default values
[attachment=1:qxxbjef6]Imagen 2.png[/attachment:qxxbjef6]

8 octaves and 0.65 falloff
[attachment=0:qxxbjef6]Imagen 3.png[/attachment:qxxbjef6]

as you can see, we don’t get the expected spikiness in the of version.

I’ve been wandering around the code and can’t really spot what is missing (they’re almost the same), do you have a clue?

thanks!
jesús.

![](http://forum.openframeworks.cc/uploads/default/259/Imagen 2.png)

![](http://forum.openframeworks.cc/uploads/default/260/Imagen 3.png)

Hi
thanks for reporting these bugs.
no, i don’t know why its not giving the expected results… the code is pretty much the same as the original noise classes, so its probably something i screwed up when porting.

I don’t have time right now to check whats going on but i’ll have a look probably tomorrow and upload a corrected version.
i’ll post here when i do.

sorry for the trouble.

Rui

Hi.

the corrected version can be found here: http://code.google.com/p/ruicode/
the problem was that one of the variables was set to int instead of float… :S
this was causing that only the first octave was being calculated, no matter how many you had set.
this is an important bug and anyone who had downloaded this should get this version instead. sorry for the trouble.

anyway, it all seems to be working now and thanks for pointing this out, i usually dont mess around too much with those settings it would have taken me a long time to find that bug.

Rui

hey thanks!

In the meantime I switched to using memo’s ofxPerlin, which at the beginning couldn’t make work until I realised it was expecting values between 0 and 1, but if time permits I will get back to using yours, as in memo’s version you can’t set the noiseDetail on the fly.

anyway, will test it again and let you know.

edit: just tested and it does work. thanks!

best,
jesús.

Hello,

Any ideas why ofxNoise doesnt working with mac os x 10.5.7 the problem is here (i think)

float ofxPerlin::noise_fsc(float i){
return 0.5f * (1.0f - perlin_cosTable[(int)(i * perlin_PI) % perlin_TWO_PI]);
}

my app compiles but crashes…

Thanks.

Hi.

i’m on osx 10.5.6 and it works fine.
i dont see why that line would make your app crash…
can you post some code? or a zip of your source so i can have a look?

thanks
Rui

Hi Rui,

source code http://www.spirosgerokostas.com/-files/-…-ticles.zip

as i said in previous post the problem is with 10.5.7.

Thanks

Spiros.

Hi Spiros,

sorry for the late reply
i updated to 10.5.7 and tried your project but i couldn’t make it compile because it couldn’t find the icon file,
but copying your source into a new project it works just fine so i don’t know whats going on but i dont think it has to do with ofxNoise…
i also tried a lot of my old apps that use ofxNoise with 10.5.7 and they all work fine.

cheers

rui